Check out my first novel, midnight's simulacra!

Sed

From dankwiki
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

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.