Skip to content
Learn Netverks

Lesson

Step 15/36 42% through track

pipes-bash

Pipes

Last reviewed May 28, 2026 Content v20260528
Track mode
none
Means
Read / quiz
Reading
~1 min
Level
beginner

This lesson

This lesson teaches Pipes: the syntax, patterns, and safety habits you need before advancing in Bash.

Virtual environments isolate dependencies—production deploys pin versions in requirements.txt or poetry.lock.

You will apply Pipes in contexts like: Log analysis, one-off data transforms, and ad hoc file searches on servers.

Read each lesson, copy bash examples into your own terminal, and complete the lesson MCQs—there is no in-browser runner for security reasons.

When you can explain the previous lesson's ideas without copying starter code.

A pipe connects stdout of one command to stdin of the next— the Unix “text as interface” pattern that makes small tools powerful.

Basic pipes

ls | wc -l
cat /etc/passwd | head -3
cat /etc/passwd | grep bash | head -2

Each stage should do one job well—compose instead of writing monolithic scripts.

Pipeline exit status

false | true
echo "pipe status: ${PIPESTATUS[0]} ${PIPESTATUS[1]}"

PIPESTATUS holds exit codes for each command in the last pipeline (Bash).

tee

echo "data" | tee copy.txt | wc -c

tee writes a copy to a file while passing data downstream—handy for logging and processing.

Important interview questions and answers

  1. Q: What does | do?
    A: Connects stdout of the left command to stdin of the right.
  2. Q: PIPESTATUS vs $?
    A: $? reflects the last command in the pipeline; PIPESTATUS lists each stage.

Self-check

  1. Which command counts lines in ls output?
  2. What variable stores per-stage exit codes in Bash?

Tip: With set -o pipefail, any failing stage fails the pipeline—essential in scripts.

Interview prep

Pipe connects?

Left stdout to right stdin.

pipefail?

Pipeline fails if any command fails.

Interview tip Lesson completion confidence

Can you explain this lesson in 30 seconds without reading notes?

Not saved yet.

Check yourself

Multiple choice — immediate feedback.

Discussion

Past discussion is visible to everyone. Only logged-in users can post comments and replies.

Starter discussion topics

  • Pipe stderr?
  • pipefail idea?

Sign up or log in to post comments and sync lesson progress across devices.

No discussion yet. Be the first to ask a question.

Jump