I have a function in bash that outputs a bunch of lines to stdout. I want to combine them into a single line with some delimiter between them.
Before:
one
two
three
After:
one:two:three
What is an easy way to do this?
\n Seems to do the trick for you.
The -s option can let it merge lines row-wise. Also, we told the paste command to separate merged lines using a given delimiter character by passing -d ” or -d ','.
Use paste
$ echo -e 'one\ntwo\nthree' | paste -s -d':'
one:two:three
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With