Piping Data
Many Linux commands can be used in concert in a single, connected command line to transform data from one form to another. Stringing Linux commands together in this fashion is known as using or creating pipes. Pipes are created on the command line with the bar operator (|). For example, you can use a pipe to perform a complex task from a single command line like this:
matthew@seymour:~$ find /d2 -name '*.txt' -print | xargs cat | \tr ' ' '\n' | sort | uniq >output.txt
This example takes the output of the find command to feed the cat command (via xargs) the name of all text files in the /d2 directory. The content of all matching files is then fed through the tr command to change each space in the data stream into a carriage return. ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access