1. Pipe to wc
| feeds cat's stdout into wc -l, which counts the lines flowing through.
cat access.log | wc -lTyporithm · medium
Step 1 of 8 · intro card
Text Processing
| pipes one command's stdout into the next command's stdin to compose filters. > redirects stdout to a file (truncating it), >> appends, and 2> redirects stderr separately — here to /dev/null to discard it.
A pipe (|) connects the stdout of the command on its left to the stdin of the command on its right, letting you chain small filters into a pipeline. cat access.log | wc -l streams the file straight into the line counter.
Redirection sends a stream to a file instead of the terminal. > overwrites (truncates) the target, while >> appends to whatever is already there — so echo "hi" > out.txt then echo "more" >> out.txt leaves two lines.
Streams are numbered: 1 is stdout and 2 is stderr. 2> redirects only the error stream, so grep error log.txt 2> /dev/null shows matches but silently drops any error messages by sending them to /dev/null.
| sends stdout into the next command's stdin.
> truncates a file; >> appends to it.
2> redirects stderr (e.g. to /dev/null to discard).
cat access.log | wc -l
sort names.txt | uniq -c
echo "hi" > out.txt
echo "more" >> out.txt
grep error log.txt 2> /dev/nullConnect each part of the code to the concept before you type.
| feeds cat's stdout into wc -l, which counts the lines flowing through.
cat access.log | wc -lsort groups equal lines together so uniq -c can count each run — the classic counting combo.
sort names.txt | uniq -c> writes echo's stdout to out.txt, truncating the file first.
echo "hi" > out.txt>> appends to out.txt instead of truncating it.
echo "more" >> out.txt2> redirects file descriptor 2 (stderr); sending it to /dev/null throws error messages away.
grep error log.txt 2> /dev/nullRead the concept map and follow the code breakdown.
Type the implementation, repair mistakes and work through every recall exercise.
Use the final check without hints; revisit weak concepts in short practice sessions.