awk code question
1
0
Entering edit mode
7.7 years ago
rbronste ▴ 420

Quick question for those that use awk often, what would the following command do to a narrowPeak file:

awk '{if ($8 > 8) print}'

Thanks

awk • 1.3k views
ADD COMMENT
2
Entering edit mode

I don't know what a narrowPeak file looks like (it would help if you showed an example in your post), but that would print the entire line, where column 8 is greater than 8. I typically use a syntax such as this:

awk -F'\t' '{if($8>8) { print } }' infile.txt
ADD REPLY
0
Entering edit mode

enter image description here

So basically I am trying to modify the following command:

zcat $dnase | awk '{if ($8 > 8) print}' | gzip > $dnase_gt8

The command is designed for the narrowPeak file (example above) but I have another file I would like to use with only 5 columns.

ADD REPLY
4
Entering edit mode
7.7 years ago
awk '{if ($8 > 8) print}'

using any number of spaces as the delimiter and for any string, if the integer value of the 8th column is greater than 8, then print the whole line.

Which can be simplified as

awk '($8>8)'
ADD COMMENT
1
Entering edit mode

just need awk '$8>8'

ADD REPLY
0
Entering edit mode

Thank you, extremely helpful!

ADD REPLY
0
Entering edit mode

It it answers the question please mark it as answered to close it (green tick on the left).

ADD REPLY

Login before adding your answer.

Traffic: 1312 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6