Learning machine learning? Try my machine learning flashcards or Machine Learning with Python Cookbook.
Chain Multiple Commands
Most commands take in some input and return some output. In Linux, we can use this feature to chain together multiple commands, each one taking the standard output of the previous command as its standard input. We can do this using the pipeline operator, |
.
Create Example Files
touch sales.txt marketing.txt operations.txt hr.txt procurement.txt devops.txt
Create A Pipeline
ls
and sort
are two commands. In this example we pipe the standard output of ls
into the standard input of sort
and then see sort
’s standard output. This simple example pipeline chain only contains two commands but often chains contain three or four commands.
ls | sort
devops.txt
hr.txt
marketing.txt
operations.txt
procurement.txt
sales.txt