Skip to content
CodeItRaw
Terminal Basics

Lesson 5/5

Here is the terminal's real power: each command does one small job, and | (the pipe) makes one command's output the next one's input. You solve a large job with a chain of small commands instead of one giant command.

grep WARN app.log | wc -l
cut -d" " -f1 visits.log | sort | uniq -c | sort -rn | head -n 3
grep WARN app.log > warnings.txt
The first line counts the warning lines (wc -l counts lines). The second is a classic: take the first column of every line, sort, count the equal ones (uniq -c), sort by the count from large to small, show the top three. The third writes the result to a file instead of the screen.

Build a pipeline step by step: run the first command and look at its output, then add one | and look again. If something in the middle of the chain is not what you expect, you see at once where it went wrong.

Tasks

Tasks open in order. Solve them all and the next lesson opens.

This lesson's tasks open when the lessons before it are finished. You can read the explanation now.Go to the current lesson

  1. 01

    Pipes

    Terminal task

  2. 02

    Save the output

    Terminal task

  3. 03

    Top visitor

    Terminal task

If you would rather not wait for the order, every problem is open without locks: Problem list