How to process every other line in bash

Viewed 32630

I would like to print odd lines (1,3,5,7..) without any change, but even lines (2,4,6,8) process with pipeline beginning with grep. I would like to write everything to new file (odd lines without any change and new values for even lines).

I know how to print every other line in awk:

awk ' NR % 2 == 1 { print; } NR % 2 ==0 {print; }' file.fasta

However, for even lines, I dont want to use {print; } but I want to use my grep pipeline instead.

An advice will be appreciated. Thanks a lot.

3 Answers
Related