Challenge - 5 Problems
Head and Tail Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate1:30remaining
Output of head command with line count
What is the output of the command
head -n 3 sample.txt if sample.txt contains these lines?Line1 Line2 Line3 Line4 Line5
Linux CLI
head -n 3 sample.txtAttempts:
2 left
💡 Hint
head shows the first lines of a file.
✗ Incorrect
The
head -n 3 command prints the first 3 lines of the file.💻 Command Output
intermediate1:30remaining
Output of tail command with byte count
What is the output of
tail -c 5 sample.txt if sample.txt contains exactly HelloWorld?Linux CLI
tail -c 5 sample.txtAttempts:
2 left
💡 Hint
tail -c shows last bytes, counting characters.
✗ Incorrect
The last 5 characters of 'HelloWorld' are 'World'.
🔧 Debug
advanced2:00remaining
Effect of tail -n with negative number
You run
Choose the correct statement.
tail -n -3 sample.txt. What happens?Choose the correct statement.
Linux CLI
tail -n -3 sample.txtAttempts:
2 left
💡 Hint
Check tail manual for allowed values of -n. Negative numbers indicate 'all but last N lines'.
✗ Incorrect
The command syntax is incorrect; tail does not accept negative numbers with -n option. It will produce an error.
🧠 Conceptual
advanced2:00remaining
Combining head and tail to get middle lines
You want to extract lines 4 to 6 from a file named
data.txt. Which command correctly does this?Attempts:
2 left
💡 Hint
Use head to get first 6 lines, then tail to get last 3 of those.
✗ Incorrect
head -n 6 gets first 6 lines; tail -n 3 extracts lines 4,5,6 from those.
🚀 Application
expert2:30remaining
Script to monitor last 10 lines of a growing log file
You want to write a script that continuously shows the last 10 lines of
app.log as it grows, updating in real-time. Which command achieves this?Attempts:
2 left
💡 Hint
Use tail with follow option to watch file growth.
✗ Incorrect
tail -f -n 10 shows last 10 lines and updates as file grows.