Pipes and redirection
Connect commands and send output where you want it.
What you will be able to do
- Use | to chain commands.
- Use > to overwrite and >> to append.
- Use 2> for errors and 2>&1 to merge streams.
- Use tee to write and display at once.
In plain English
A pipe sends stdout of one command to stdin of another. Redirection writes stdout to a file with > (overwrite) or >> (append), and 2> captures stderr. Small commands composed with pipes solve big problems.
ls -la | grep ".md" | wc -l
echo "build started" >> build.log
npm run build 2>&1 | tee build.logYour turn
EasyCount Markdown files
Count the .md files in the current directory using a pipe.
BASH · starter
lsCheck your understanding before moving on.
Knowledge checkQuestion 1
Which operator appends output to a file?
Select an answer to continue
Study tools
Make it yours.
Keep a private note for this lesson, then turn the key ideas into flashcards you can revisit.
Sign in to save notes and flashcards.Both are private to your account and stay with your progress.
Sign inFinished reading?
Lock in what you just learned.
0%
Mark this lesson complete to save your place and move one step closer to the certificate.