A simple command-line tool that joins multiple lines from stdin into a single line with a specified separator.
cat file.txt | implode
#line1 line2 line3
cat file.txt | implode -s ","
#line1,line2,line3
echo -e "line1\nline2\nline3" | implode -s " | "
#line1|line2|line3-s- Separator character/string to join lines (default: space " ")
Join lines with default space separator:
$ echo -e "hello\nworld"
hello
world
$ echo -e "hello\nworld" | implode
hello worldJoin lines with custom separator:
$ echo -e "apple\nbanana\ncherry" | implode -s ","
apple,banana,cherryThe name "implode" is used since join is already a command on most Unix-like systems (used for joining lines of two files on a common field).
go install github.com/penguinpowernz/implode@latestOr build from source:
git clone https://github.com/penguinpowernz/implode
cd implode
go build -o implode .