Removing unwanted lines in text file

awksedtext processing

All I need is the sed or awk code to remove the even numbered lines in a text file. Nothing fancy I just need to remove irrelevant data on the even lines of a text file.

Best Answer

Simply:

sed 'n;d' file

for even lines, and

sed '1!n;d' file

for odd lines.

With the GNU implementation of sed, you can also use this syntax:

Odd:

sed '1~2d' file

Even:

sed '2~2d' file
Related Question