March 2018
Beginner to intermediate
416 pages
9h 24m
English
In this method, the output of a shell command can be piped into the getline using "command" | getline, which can be further used to generate output. The following examples illustrate how this method works:
$ vi getline_pipe.awkBEGIN { "date" | getline print "Date is : ", $0 close("date") print "=====================" print "DISK FREE SPACE INFO" print "=====================" # using loop to print multiple lines while (("df -h" | getline) > 0 ) print "Disk info : ", $0 close("df -h")}$ awk -f getline_pipe.awk
The output of the execution of the preceding code is as follows:
Date is : Wed Mar 7 00:13:17 IST 2018=====================DISK FREE SPACE INFO=====================Disk info : Filesystem Size Used ...
Read now
Unlock full access