In Shell, I have output of a unix command as
test1
test2015
but I want it as
test1 test2015
can anyone help me out.
In Shell, I have output of a unix command as
test1
test2015
but I want it as
test1 test2015
can anyone help me out.
Hello OscarS,
Welcome to forums, please use code tags as per forum rules to codes/Inputs/commands used in your posts as per forum rules. Now coming on to your request, you haven't mentioned which command you have used to get the shown output, you could following and let me know if that helps.
Your_command | awk '{A=A?A OFS $0:$0} END{print A}'
In case you need to get input from a file then you could use as follows.
awk '{A=A?A OFS $0:$0} END{print A}' Input_file
As always on a Solaris/SunOS system, change awk
to /usr/xpg4/bin/awk
, /usr/xpg6/bin/awk
, or nawk
.
Thanks,
R. Singh
Or, more simply:
your_command | tr '\n' ' ';echo
Or
echo $(your_command)