Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I like using paste to convert a list of lines into a single line, comma-delimited list...

Contrived example, for brevity:

    awk 'BEGIN { while (i < 10) print i++ }' | paste -sd, -
or maybe:

    ls *txt | paste -sd, -


I like using paste to sum over numbers where each number is in a distinct line. E.g.:

     printf "1\n2\n3" | paste -sd+ | bc
    6
I suppose you could do that more cleanly with awk, but this has worked whenever I needed it. I find it easier to type.


I'd just do that with tr '\n' ,

It's fascinating that there are so many different ways to do things, even within the limited confines of coreutils!


Fwiw you can do that with just awk, no pipe and paste required


    seq 10 | paste -sd, -




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: