Selecting two sets of conditions in awk
The problem is that you are using an assignment operator (=
) rather than a test of equality (==
). The boolean result of assigning zero to something is "false". This is why the test never succeeds.
The idiomatic awk
command would be
awk '($1 >= 1 && $2 == 0) || ($1 == 0 && $ 2 >= 1)'
The { print $0 }
is not needed as this is the default action for any condition that does not have an action.
If you just want to skip lines with the same values in column one and two (gives the same output for the given data):
awk '$1 != $2'
The output in both cases is
1 0
0 1
Beside of the problem you had in your awk
command using =
instead of ==
for comparison that Kusalananda pointed that. What I understood from your input and the command you are using, you want those line when at least one of those are zero).
Assuming you don't have negative values, then you could use:
awk '($1 && !$2) || (!$1 && $2)' infile
Or even shorter (you can use -
as well).
awk '($1 * !$2) + (!$1 * $2)' infile