November 2017
Intermediate to advanced
386 pages
9h 22m
English
The first solution we'll use implies adding a function to the pipeline, which will just log its input. We want to implement something similar to the tee Linux command, which can intercept the standard data flow in a pipeline and send a copy to an alternate file or device. Remembering that /dev/tty is the usual console, we may execute something as follows and get an onscreen copy of everything that passes through the tee command:
$ ls -1 | grep "odt$" | tee /dev/tty | wc -l...the list of files with names ending in odt...4
We could write a similar function with ease:
const tee = arg => { console.log(arg); return arg;};