Reputation: 1449
i ve the following problem: I have a file like:
1 3 4
2 5 6
3 1 3
4 1 0
5 7 0
6 0 1
and I would like to delete a line that contains in the second column 1 and in the third one the number 0. So the result should be:
1 3 4
2 5 6
3 1 3
5 7 0
6 0 1
I've tried with: awk '$2!=1 && $3 != 0' file
but it will delete also the lines: '5 7 0' and '3 1 3'
Any help?
Upvotes: 3
Views: 2863
Reputation: 121357
This will ensure that:
awk '!($2==1 && $3==0){print}' file
i.e. print all lines except those with 2nd column is 1 and 3rd is 0.
Upvotes: 2
Reputation: 212218
You want:
awk '!( $2==1 && $3 == 0)' file
or, equivalently:
awk '$2 != 1 || $3' file
Upvotes: 6
Reputation: 363517
You're looking for the negation of $2 == 1 && $3 == 0
. By the rules of logic, that's
awk '$2 != 1 || $3 != 0'
Upvotes: 3