The $0 variable

The entire line that is copied into the buffer, such as a record, is called $0.

Take the following command, for example:

    $ cat people.txt
  

The output is will be as follows:

    Bill Thomas  8000  08/9/1968
    Fred Martin  6500  22/7/1982
    Julie Moore  4500  25/2/1978
    Marie Jones  6000  05/8/1972
    Tom Walker   7000  14/1/1977
    $ awk '{print $0}' people.txt
  

The output is as follows:

    Bill Thomas  8000  08/9/1968
    Fred Martin  6500  22/7/1982
    Julie Moore  4500  25/2/1978
    Marie Jones  6000  05/8/1972
    Tom Walker   7000  14/1/1977
  

This has printed all the lines of the text file. Similar results can be seen with the following command:

    $ awk '{print}' people.txt
  

Get Learning Linux Shell Scripting - Second Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.