Shell Programming
A Necessity for all Programmers
Pipe Operators
Nagesh Karmali | Firuza Karmali
Department of Computer Science and Engineering
IIT Bombay
You will learn to ...
• Use pipe operators
Shell Programming – A Necessity for all Programmers By Nagesh | Firuza 2/6
Pipe Operators
• STDOUT and file
• Example 1: ls -l | more
• Example 2: ls -l | tee file.txt
• (| pipe operator: combines two or more commands)
• data/output flows from left to right
• Append to a file: -a
• Example 3: ls -l | tee -a file.txt
Shell Programming – A Necessity for all Programmers By Nagesh | Firuza 3/6
Pipe Operators
• Send output of one command to input of next command
• Use of pipe |
• Connect multiple commands using pipes
• cmd1 | cmd2 | ... | cmdN
• Example 4: ls | wc -l | tee size.txt
Shell Programming – A Necessity for all Programmers By Nagesh | Firuza 4/6
Now, you can ...
• Redirect command output to terminal and file
• Append command output to file
• Using pipe operator to send the output of one command to other
Shell Programming – A Necessity for all Programmers By Nagesh | Firuza 5/6
Thank you
1
Shell Programming – A Necessity for all Programmers By Nagesh | Firuza 6/6