I was doing some data filtering and noticed something a bit strange.
As we all know, awk '1' is short for awk '{print $0}', since 1 evaluates to True and triggers that default action on Awk, which consists on printing the current record.
Similarly, awk '0' does not print anything because it evaluates to False.
$ seq 3 | awk '0'
                      # nothing
$ seq 3 | awk '1'
1
2                     # everything
3
So I tried different approaches on this and noticed that awk '-1' gives an error, while awk '(-1)' works without a problem:
$ seq 3 | awk '-1'
Usage: awk [POSIX or GNU style options] -f progfile [--] file ...
Usage: awk [POSIX or GNU style options] [--] 'program' file ...
POSIX options:      GNU long options: (standard)
...
        # all the gawk explanation on how to use it
...
$ seq 3 | awk '(-1)'
1
2                     # everything, since apparently
3                     # -1 evaluates to True
The same with awk '-NF' or awk '-NR' or any other expression starting with the negative character.
Why is this?
I am on GNU Awk 4.1.65, API: 2.0.
 
     
    