Reputation: 1
I have a file and I am trying to get this following information. There are a few headers and my condition is as follows that returns the count of time "PO" is found in column 5.However I want to print the entries that match the criteria as well. How do I do that?
awk 'BEGIN {count = 0} $5 == "PO" && $13 <0.01 {count++} END {print(count)}' 1.genome
Upvotes: 0
Views: 50
Reputation: 1875
You can do multiple things inside the curly braces. If you keep it as a one-liner, separate each command by a semicolon. E.g.
awk 'BEGIN {count = 0} $5 == "PO" && $13 <0.01 {print $0; count++} END {print count}' 1.genome
As the complexity grows, you may want to format it on multiple lines:
awk '
BEGIN {
count = 0
}
$5 == "PO" && $13 < 0.01 {
print $0
count++
}
END {
print count
}
' 1.genome
Upvotes: 1