March 2018
Beginner to intermediate
416 pages
9h 24m
English
This is the simplest way to use the getline command. In this method, we specify the getline command without any arguments in the body block to read the next input line from the current input file. It reads the next input record and splits it into fields. The following example illustrates how the simple getline command works:
$ awk '{getline; print NR,$0;}' cars.dat
Here, at the beginning of body block, before executing any statement, AWK reads the first line from the current input file and stores it in $0. The getline command is the first statement in the body block, and makes AWK read the next line from the current input file and store it in the $0 variable. Thus, on execution of the $0 print command, it prints the second ...
Read now
Unlock full access