How can I conserve the blanks when I assign to env variable?
Hi All,
I'm working on Compaq Computer Corporation Tru64 UNIX V5.1. see I need store the result of this command in a env variable: (please where you see "-" is blanks) $ sed -n 3p file 0000311CDS-009384---------------0.00------------0.00-----------0.00 this is my result: $ line=`sed -n 3p file` $ echo $line 0000311CDS 009384 0.00 0.00 0.00 I need conserve the blanks! but these are removed. IMPORTANT NOTE!: I found the same frustation making this thread! if i write consecutive blanks these are automatically removed after post, thats is why I replaced the " " by "-". Could you please help me?? Thanks in advace!!! |
Ignore what I said, the problem was in the quoting, not the field separator.
|
It is probably only removing the blanks when you print (echo), they should still be in the variable. Quoting it should solve the problem.
Code:
echo "$line" |
Two things are at play here. First, if you post your formated text in [CODE] tags, the formatting will be preserved.
Second, the spaces are kept intact when assigned to your variable. If, however, you pass the variable as an argument to a function or as a commandline argument, the shell will expand it into multiple whitespace-delimited arguments. If you want the variable to be used as a single argument, then enclose it in double quotes: Code:
grep "$line" file |
Thanks guys!!!
|
All times are GMT -5. The time now is 03:11 AM. |