abrd600
February 14, 2005, 4:27am
1
Hi,
I have given the following statement in a script to put the values of variables (VAR1, VAR2,...) in a file.
echo " $VAR1 $VAR2 $VAR3 $VAR4 $VAR5" >> filename
But the output is not coming properly. Variables VAR5, VAR4 are replacing the first (VAR1, VAR2,..). I can't figureout the reason. Say
VAR1=50; VAR2=51; VAR3=52; VAR4=53; VAR5=54;
Output: 53 54 52 (Something like this)
But if you echo each variable separately it is echoing properly.
Can anyone help me on this ?
Thanks
Ben
Kinki
February 14, 2005, 4:38am
2
Hi,
Your scripts works fine, didn't encounter the problem u mentioned. Not sure why u have such problem. I just test out these two sentences. Look at your syntax again. u must have put the variable in echo at the wrong order.
VAR1=50; VAR2=51; VAR3=52; VAR4=53; VAR5=54;
echo " $VAR1 $VAR2 $VAR3 $VAR4 $VAR5" >> testtest
abrd600
February 14, 2005, 8:41am
3
If we assign values then it would work fine.
But if we get values from files & then echo them there'll be problem.
Ben
esham
February 14, 2005, 12:05pm
4
hello..
For me ..its working fine...even assigning values during execution..
please check the code once more. there might me some other problems
regards
esham
bhargav
February 14, 2005, 12:46pm
5
try putting tabs in between the varaibles
echo " $VAR1\t $VAR2\t $VAR3\t $VAR4\t $VAR5\t" >> filename
Just a note that some versions of echo (notably Linux) require the "-e" option to enable interpretation of backslash-escaped sequences, e.g.
echo -e "blah\tblah\tblah"
Cheers
ZB