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 ...

Get Ubuntu Unleashed 2014 Edition: Covering 13.10 and 14.04,Ninth Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.