0
0
Linux CLIscripting~20 mins

tee for splitting output in Linux CLI - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Tee Mastery Badge
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate
2:00remaining
What is the output of tee command?
Consider the command:
echo "Hello World" | tee file.txt
What will be the output on the terminal?
Linux CLI
echo "Hello World" | tee file.txt
Afile.txt
BHello World
CNo output
DError: tee command not found
Attempts:
2 left
💡 Hint
tee prints the input to both the file and the terminal.
💻 Command Output
intermediate
2:00remaining
What happens when tee is used with -a option?
Given the command:
echo "New Line" | tee -a file.txt
What is the effect on file.txt?
Linux CLI
echo "New Line" | tee -a file.txt
Afile.txt is overwritten with 'New Line'
Bfile.txt is deleted
Cfile.txt is appended with 'New Line'
DError: invalid option -a
Attempts:
2 left
💡 Hint
The -a option means append.
💻 Command Output
advanced
2:00remaining
What is the output of tee with multiple files?
What will be the result of:
echo "Data" | tee file1.txt file2.txt
on the terminal and files?
Linux CLI
echo "Data" | tee file1.txt file2.txt
AOutputs 'Data' on terminal and writes to file1.txt and file2.txt
BOutputs 'Data' only on terminal, files remain empty
CWrites 'Data' only to file1.txt, no terminal output
DError: tee accepts only one file
Attempts:
2 left
💡 Hint
tee can write to multiple files at once.
💻 Command Output
advanced
2:00remaining
What error occurs with invalid tee usage?
What error message appears when running:
echo "Test" | tee -z file.txt?
Linux CLI
echo "Test" | tee -z file.txt
Atee: invalid option -- 'z'
BTest
CNo output, no error
Dfile.txt contains 'Test'
Attempts:
2 left
💡 Hint
Invalid options cause an error message.
🚀 Application
expert
3:00remaining
How to save and display command output simultaneously?
You want to run ls -l and save its output to listing.txt while also seeing it on the terminal. Which command achieves this?
Als -l >> listing.txt
Bls -l > listing.txt
Ctee listing.txt < ls -l
Dls -l | tee listing.txt
Attempts:
2 left
💡 Hint
tee duplicates output to file and terminal.