Friday, November 4, 2011

Getting the odd lines

Hi, if you have to display only the odd lines from the file we can try
let file
$ cat myfile.txt
1
2
3
4
5
6
7
8
9

$ sed -ne '1~2p' myfile.txt
1
3
5
7
9

$ awk '{if (NR%2==1) {print;} }' myfile.txt
1
3
5
7
9