How can I remove every odd line, using sed?
remove
keep
remove
keep
remove
...
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
GNU sed has a suitable addressing mode:
which means, starting from line 1, and with step 2, print all other lines.
Equivalently, you can drop the
-n, and delete matching lines:It can also be done using awk:
(Whenever line number is a multiple of 2, print the line)