views:

116

answers:

2

How can I remove every odd line, using sed?

remove
keep
remove
keep
remove
...
+2  A: 
sed -n '1~2!p' file

awk 'NR%2==0' file
ghostdog74
+1  A: 

Here is the shortest I can think of:

sed -n 'g;n;p' file

It should work with non-GNU versions of sed (as well as GNU sed).

Dennis Williamson