print ODD lines

i want to print ODD lines like first ,third then fifth and so on

234,567,ABC,KJL
234,565,ABD,KJL
234,568,ABE,KJL
234,560,ABF,KJL
234,563,ABG,KJL
234,562,ABH,KJL

O/P will be like

234,567,ABC,KJL  ----->first liine
234,568,ABE,KJL  ----->third line
234,563,ABG,KJL  ----->fifth line and so on.....

Please help me

1 Like

Try...

awk 'NR%2' file1

Hi,

sed -n '1~2 p' infile

Regards,
Birei

Could you pls tel how this works.. 1~2 p

perl -ne 'print if($.%2)' file

Hi,

Beginning in first line, prints one each two: First, third, fifth, etc.

Regards,
Birei

Note: ~ is GNU sed only. Alternatively use:

sed 'n;d' file