how to concatenate lines into one string

bash, shell

Solution

Use `paste`

$ echo -e 'one\ntwo\nthree' | paste -s -d':'
one:two:three

Problem

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?

Original source