Show only odd lines with cat

bash

HI,

probably is this something very easy, but I do not get the point now. In Linux, shell, given a text file, how can I do something like, cat filename so I only see the first line, the third line, 5, 7, 9 and so on?

if not with cat, with another command

Thanks

Best Answer

Using awk: awk 'NR % 2 == 0' filename

Edit: removed {print}, as shown in ghostdog74's answer and commented on by Roberto Bonvallet.

Related Question