echo problem

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

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

If we assign values then it would work fine.

But if we get values from files & then echo them there'll be problem.

Ben

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

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