March 2018
Beginner to intermediate
416 pages
9h 24m
English
This option is used to read the program source from the source file instead of in the first non-option argument. If this option is given multiple times, the program consists of the concatenation of the contents of each specified source file:
-f source-file
--file=source-file
First, we will create 2 programs to print line number 2 and line number 4, respectively. Then, we will use the -f option to source those files for execution with the interpreter, as follows:
$ vi f1.awkNR==2 { print NR, $0 } $ vi f2.NR==4 { print NR, $0 }
Now, first use only f1. for sourcing:
$ awk -f f1.awk cars.dat
This can also be performed as follows:
awk --file=f1.awk cars.dat
The output on execution of this code is as follows: ...
Read now
Unlock full access