上QQ阅读APP看书,第一时间看更新
Action-only statements
The syntax of the awk command with an action only is as follows:
awk '{ action statements / awk-commands }' inputfilenames
If you omit the pattern and give the action statement (AWK commands), then the given action is performed on all input lines, for example:
$ awk '{ print $1 }' empinfo.txt
Jack
Jane
Eva
amit
Julie
In the given example, all employee names are printed on the screen as $1, representing the first field of each input line.
An empty pattern, that is / /, matches the null character and is equivalent to giving no pattern at all. If we specify an empty pattern, it will print each input record of the input file. An empty action, that is { }, specifies that doing nothing will not print any input record of the input file.