Challenge - 5 Problems
Pipe Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate2:00remaining
What is the output of this command pipeline?
Consider the following command pipeline:
What is the output?
echo -e "apple\nbanana\ncherry" | grep 'a' | wc -l
What is the output?
Linux CLI
echo -e "apple\nbanana\ncherry" | grep 'a' | wc -l
Attempts:
2 left
💡 Hint
Count lines containing the letter 'a' after filtering.
✗ Incorrect
The echo command outputs three lines: apple, banana, cherry. grep 'a' filters lines containing 'a': apple and banana. wc -l counts these lines, resulting in 2.
💻 Command Output
intermediate2:00remaining
How many lines are printed by this pipeline?
What is the output count of lines from this command?
How many lines are printed?
seq 5 | awk '{print $1 * 2}' | grep -v '^4$'How many lines are printed?
Linux CLI
seq 5 | awk '{print $1 * 2}' | grep -v '^4$'
Attempts:
2 left
💡 Hint
Check which numbers are filtered out by grep -v '^4$'.
✗ Incorrect
seq 5 outputs 1 to 5. awk multiplies each by 2: 2,4,6,8,10. grep -v '^4$' removes line '4' only. So lines printed are 2,6,8,10 → 4 lines.
📝 Syntax
advanced2:00remaining
Which pipeline produces the output 'hello' correctly?
You want to print 'hello' using a pipe. Which command works correctly?
Attempts:
2 left
💡 Hint
Remember what the pipe operator does: it sends output of left command as input to right command.
✗ Incorrect
Option D pipes 'hello' into cat, which outputs 'hello'. Option D: echo world ignores stdin and outputs 'world'. Option D uses && (not pipe) and outputs 'hello\nworld'. Option D: grep finds no match, no output.
🔧 Debug
advanced2:00remaining
Why does this pipeline produce no output?
Examine this command:
Assuming 'file.txt' contains lines with 'pattern' but none with 'nomatch', why is there no output?
cat file.txt | grep 'pattern' | grep 'nomatch'
Assuming 'file.txt' contains lines with 'pattern' but none with 'nomatch', why is there no output?
Linux CLI
cat file.txt | grep 'pattern' | grep 'nomatch'
Attempts:
2 left
💡 Hint
Think about how grep filters lines and how pipes pass output.
✗ Incorrect
The first grep filters lines containing 'pattern'. The second grep looks for 'nomatch' in those lines. Since none contain 'nomatch', no lines pass through, so output is empty.
🚀 Application
expert3:00remaining
Which pipeline counts unique words in a file correctly?
You want to count how many unique words appear in 'document.txt'. Which pipeline produces the correct count?
Attempts:
2 left
💡 Hint
Think about how to split words into separate lines before sorting and counting unique entries.
✗ Incorrect
Option A replaces spaces with newlines, so each word is on its own line. Then sorting and uniq count unique words correctly. Other options either don't split words properly or misuse commands.