Sed

From dankwiki

The stream editor. Sometimes the shitty editor. sed works on lines at a time (mostly). Note that GNU and POSIX sed differ in some significant ways.

Use -i to run sed on a file inline. Never use e.g. cat file | sed > file; the shell redirection is going to open file for writing with truncation, which is probably not what you want. Supply expressions on the command line with -e, and/or files of expressions with -f.

Recipes

Join pairs of lines

sed 'N;s/\n/ /' replaces every other newline with a space. Replace the space with whatever you want.