extract lines in a text file using Awk

In bioinformatics, one commonly needs to extract some data from a big text file to check the data. The following code in Awk helps to do this:

awk ‘0 == (NR-1) % 100’ big_file.txt > small_file.txt

It extracts 1 line every other 100 lines in a text file, including the first line.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s