Using paste command:
paste -d, -s file
file
aaa
bbb
ccc
ddd
xargs
cat file | xargs
result
aaa bbb ccc ddd
xargs improoved
cat file | xargs | sed -e 's/ /,/g'
result
aaa,bbb,ccc,ddd
Using paste command:
paste -d, -s file
aaa
bbb
ccc
ddd
cat file | xargs
aaa bbb ccc ddd
cat file | xargs | sed -e 's/ /,/g'
aaa,bbb,ccc,ddd