Caffeinated Coder
Book an appointment
Lesson 05 · Getting around

Pipes and text tools: grep, sed, awk

Linux text tools treat text as lines, and every program reads from standard input and writes to standard output. The pipe symbol | joins one program's output to the next one's input, so small tools chain into one command. Follow four lines of scores.txt through grep fail scores.txt | sed 's/fail/retry/' | awk '{ print $1, $3 }': grep keeps the lines that match, sed edits them, and awk splits them into fields and prints the ones you ask for.

10 min10 steps5 questionsBeginner
Fig 5 · Interactive
Loading figure…
or ← →

Quiz Unlocks after the last step.