Hello,
I am trying to convert a line into a list using awk or sed.
Line:
345 897 567 098 123
output:
345
897
567
098
123
thanks
Hello,
I am trying to convert a line into a list using awk or sed.
Line:
345 897 567 098 123
output:
345
897
567
098
123
thanks
echo "345 897 567 098 123" | sed 's/ /\n/g'
echo "345 897 567 098 123" | tr ' ' '\n'
echo "345 897 567 098 123" | awk '{for(i=1;i<=NF;i++) {print $i}}'
Did you try searching the forum? There're lots of similar posts:
In nawk if missed ..
$ nawk '{gsub(/ /,"\n")};1' infile
echo "12 11 13 15" | awk 'BEGIN { RS=" "; ORS=" \n"; } {print$1; } '
How could we forget Perl!
echo "345 897 567 098 123" | perl -pe 's/ /\n/g'
And another one:
% printf '%s\n' 345 897 567 098 123
345
897
567
098
123
Hey guys thanks all of you.
tried all and the all work.
and I did try to search but did not find the links you provided
Using man tr ("tr")
echo "345 897 567 098 123" | tr \ \\\n
---------- Post updated at 06:42 AM ---------- Previous update was at 06:41 AM ----------
Already suggested by balajesuri