Bash
Delete the last N lines
$ echo -e "a\nb\nc" | head -n -1
a
b
$ echo -e "a\nb\nc" | head -n -2
a
Run multiple processes write to the same pipe
{ (echo zzz; echo aaa; echo kkk) } | sort
aaa
kkk
zzz
$ echo -e "a\nb\nc" | head -n -1
a
b
$ echo -e "a\nb\nc" | head -n -2
a
{ (echo zzz; echo aaa; echo kkk) } | sort
aaa
kkk
zzz