hi,
I am basically running a sql that returns me values and I have stored them to a variable for example value of the variable will be:
123 124 345
now I want to write values stored in the variable into a file as
123
124
345
thanks in advance
hi,
I am basically running a sql that returns me values and I have stored them to a variable for example value of the variable will be:
123 124 345
now I want to write values stored in the variable into a file as
123
124
345
thanks in advance
$ tr ' ' '\n' < infile > outfile
EDIT: sorry, from a variable you could do:
echo "$VAR" | tr ' ' '\n' > outfile
Try also:
x="123 124 345"
echo "${x// /$'\n'}"
123
124
345
Should work in recent bash, ksh.
OR
$ echo "123 124 345" | awk '$1=$1' RS=" "
123
124
345