November 2017
Intermediate to advanced
670 pages
17h 35m
English
Executing a composition or chain of functions is very much like executing a series of Bash commands, where the output from one command is piped into the next command. For example, we might cat an input a file that contains a list of timestamps and IP addresses in an awk command. The awk command removes all but the seventh column. Next, we sort the list in descending order, and finally, we group that data by unique IP addresses.
Consider the following Bash command:
$ cat ips.log | awk '{print $7}' | sort | uniq -c
Let's give this command the following input:
Sun Feb 12 20:27:32 EST 2017 74.125.196.101Sun Feb 12 20:27:33 EST 2017 98.139.183.24Sun Feb 12 20:27:34 EST 2017 151.101.0.73Sun Feb 12 20:27:35 EST 2017 98.139.183.24 ...