March 2018
Beginner to intermediate
416 pages
9h 24m
English
The fields of the current input line are called $1 and $2, through $NF. $0 represents the whole newline. Fields share the properties of other variables. These field variables can be used in arithmetic or string operations and can also be used for assignment. For example, to display the content of the cars.dat file line by line, we can use the following command:
$ awk '{print $0}' cars.dat
This can also be performed as follows:
$ awk '{print $1, $2,$3,$4,$5 }' cars.dat
The second command will change the spacing between the fields to a single space, otherwise the result remains the same.
We can modify the field value for each line using these positional parameters. For example, if we want to put DEZIRE ...
Read now
Unlock full access