Reputation: 394
I have tab delimited text file (like this):
A 1 A1g DELL
A 1 B1s HP
A 7 Zfd Nog
A 5 Jgf KIT
A 1 Def JOP
Apart from the first row, I would like to keep only the rows where the second column's value is larger than 1.
A 1 A1g DELL
A 7 Zfd Nog
A 5 Jgf KIT
I tried awk '{if($2>1) print }' file.txt
but it omits the first row. How can I skip the first row and check the condition ($2 >1)
for other rows?
Thanks in advance.
Upvotes: 1
Views: 418
Reputation: 37464
In AWK:
$ awk 'NR==1||$2>1' test.in
A 1 A1g DELL
A 7 Zfd Nog
A 5 Jgf KIT
Upvotes: 3