I have file:
xxx.lst
with values:
111
222
333
I just need to make one line with:
111 222 333
into a variable or standard output.
paste is probably the best tool for this job:
$ paste -sd ' ' file
111 222 333
paste belongs to coreutils package
You can use tr to replace line separator with space, e.g
set -f
somevar="$(tr '\n' ' ' < xxx.lst)"
echo $somevar
Xargs echo and i/o redirection.
xargs echo < xxx.lst
You don't even need the echo.
xargs < xxx.lst
Tested on ksh/aix and bash/GNU.
xargs choked on unbalance double quotes line, remove balance double quotes line.
xargs -0 < xxx.lst with GNU xargs will work with any unbalanced quote marks.