March 2018
Beginner to intermediate
416 pages
9h 24m
English
The default value of the output record separator (ORS) is a single newline by default. We assign new values to the variable ORS to change how records are separated. It is also used to create a formatted output. Let us say that we want to print each line separated by a sequence of special character asterisks, as follows:
$ vi ors.awk #!/usr/bin/awk -fBEGIN { ORS="\n**************************************************************\n"}{ print $0 }$ awk -f ors.awk emp.dat
The output of the execution of the preceding code is as follows:
Jack Singh 9857532312 jack@gmail.com M hr 2000****************************************************************Jane Kaur 9837432312 jane@gmail.com F hr 1800**************************************************************** ...
Read now
Unlock full access