Re: select alternative lines from a file



<gopikrishnan.gunasekaran@xxxxxxxxx> wrote in message news:1139592499.348584.295390@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
: hi all,
: Im using the following script to select alternative lines from a file.
: cat -n <filename> | awk '{ if ($1%2 =0) print $0)
: its output contains the line number but i dont want it, Anyone help me
: in this regard
:
: Thanks & Regards,
: Gopi Krishnan
:

To output even numbered lines

awk '!(NR%2)' filename # parentheses necessary since ! has precedence over %

To output odd numbered lines

awk 'NR%2' filename # parentheses necessary since ! has precedence over %

Dan Mercer


.