Chaining Commands with Pipes
A pipe | sends the output of one command into the next one. It lets you build small tools out of simple commands.
Chain as many as you like. Here ls feeds grep, which feeds wc -l to count the lines.
Useful filters to pipe into: grep (keep matching lines), sort (-r reverses), wc -l (count lines), head -n 2 and tail -n 2 (first or last lines).
Quick check
What does `ls | wc -l` print?
Your turn: write the code
words.txt is created for you. Use a pipe to print only its alphabetically first word.
Finish the quick check (and any code exercise) to complete this lesson, or mark it done yourself.
Tip: use the left and right arrow keys to move between lessons.