Hello, With GNU bash, version 3.00.16(1)-release (i386-redhat-linux-gnu) : # cat myfic line1 <SP><SP>line2 <TAB>line3 # # while read line line1 line2 line3 # Someone has an explanation ? and a solution ? ;-) Thanks, Christian
Hello, With GNU bash, version 3.00.16(1)-release (i386-redhat-linux-gnu) : # cat myfic line1 <SP><SP>line2 <TAB>line3 # # while read line line1 line2 line3 # Someone has an explanation ? and a solution ? ;-) Thanks, Christian
explanation: the setting of IFS solution: setting IFS more detailed, IFS is by default set to space,tab,newline. If you do not want space and newline to be used as input separators, use a different IFS. in your case, set IFS to newline Eric
53215$4561a198$c2abfc64$ XXXX@XXXXX.COM ... Thanks ! That's it. Christian
Interestingly, reading from terminal, without redirection, does not show that behaviour... $ echo -n "$IFS" | od -a 0000000 sp ht nl 0000003 $ while read line; do /bin/echo "$line" ; done | od -a a b c 0000000 a sp sp b ht c nl 0000007 # input had a tab between b and c; removed by copy/paste posting Janis
On 20 Nov 2006 05:12:29 -0800, Janis Leading and trailing spaces are stripped. $ while read line; do /bin/echo "$line" ; done | od -a ab c d[space] 0000000 a b sp c sp sp d nl 0000010 -- brain, n: The apparatus with which we think that we think. -- Ambrose Bierce, "The Devil's Dictionary"
1.GNU Bash removes blank spaces and tabs
Hello, With GNU bash, version 3.00.16(1)-release (i386-redhat-linux-gnu) : # str="1<SP><SP>2<TAB>3" # echo ${#str} # 6 So far, so good. But : # echo ${str} # 1<SP>2<SP>3 Someone have an explanation ? Thanks, Christian
2.read command removes leading spaces - how to avoid?
How can I get each line of a file subsequently into a shell without loosing leading spaces? Example: script.sh #! /bin/bash while read line do echo "${line}" done < $1 > script.sh script.sh outputs: #! /bin/bash while read line do echo "${line}" done < $1 Regards, pb
3.reading a file which is in user space from kernel space
HI, Can we read a file which is in user space from kernel space. Idea is : This file is a configuration file which contains info which is needed by the file system. so while mounting i want to read this file and keep it in memory. Regards Gururaja
4.Read chopping off space, and READ-ing binary data
Hi, If I have a string " doggy" and I READ it into var, var ends up as "doggy", with the leading spaces chopped off. How do I stop this behaviour? (Is it the IFS environment variable?) Also, does anything special have to be done to get READ to take in Binary data, i.e. anything in the whole 0-255 ASCII range? Thanks. The Nomad.
Hi, Given the program below: m3vmsa3.BIpex /tmp > cat kk.sh #!/usr/bin/ksh cat foo|read print ">>>${REPLY}<<<" m3vmsa3.BIpex /tmp > cat foo a m3vmsa3.BIpex /tmp > kk.sh >>>a<<< How can I read the "spaces" at the beginnig of the line? Thanks in advance, Jose Luis.
6. Replace tab character with spaces
Users browsing this forum: No registered users and 21 guest