skybert's Blog

skybert's Avatar Image
Coder of systems, lover of languages, follower of Christ. 台灣女婿
← All posts

TIL you can delete every second line with sed:

Example input:

very interesting
not interesting
very interesting
not at all
$ cat <file> | sed '0~2d'

If it’s the second line that’s interesting, like:

not interesting
very interesting
not at all
very interesting

You can do:

$ cat <file> | sed '1~2d'

#bash #linux #unix

To like or reply, open original post on Emacs.ch