The awk output looks like:
awk '{print $2}'
toto
titi
tata
I want to dispay the output of awk in the same line with space as separator instead of new line
awk [option] '{print $2}'
toto titi tata
Is it possible to do that?
From the manpage:
ORS The output record separator, by default a newline.
Therefore,
awk 'BEGIN { ORS=" " }; { print $2 }' file
You can always use printf
to control the output of awk
awk '{printf "%s ",$2}' file
toto titi tata
My option is the same as accepted answer but I believe my command is a bit easy to remember.
awk '{print $2 }' ORS=' '