4 ms·
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) prin
by jftuga 2y ago
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, -
- paradox460 2y agoFwiw you can do that with just awk, no pipe and paste required
- maleldil 2y agoI 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.
- tacostakohashi 2y agoI'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!
- monista 2y agoseq 10 | paste -sd, -