0
0
Linux CLIscripting~20 mins

cat (display file contents) in Linux CLI - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Cat Command Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate
1:00remaining
What is the output of this command?
You have a file named example.txt with the following content:
Hello
World

What will be the output of the command cat example.txt?
Linux CLI
cat example.txt
A
Hello
World
BHello World
CHello\nWorld
Dexample.txt
Attempts:
2 left
💡 Hint
The cat command prints the file content exactly as it is.
💻 Command Output
intermediate
1:00remaining
What happens when you use cat on multiple files?
You have two files:
file1.txt contains:
Apple

file2.txt contains:
Banana

What is the output of cat file1.txt file2.txt?
Linux CLI
cat file1.txt file2.txt
AAppleBanana
BApple\nBanana
C
Apple
Banana
Dfile1.txt file2.txt
Attempts:
2 left
💡 Hint
The cat command concatenates files and prints their contents in order.
💻 Command Output
advanced
1:00remaining
What is the output of this command with a non-existent file?
What happens when you run cat missing.txt if missing.txt does not exist?
Linux CLI
cat missing.txt
ANo output, command succeeds silently
BSyntax error
Cmissing.txt
Dcat: missing.txt: No such file or directory
Attempts:
2 left
💡 Hint
Try to think what happens when a file is not found.
💻 Command Output
advanced
1:00remaining
What is the output of this command with input redirection?
What will be the output of cat < file.txt if file.txt contains:
Line1
Line2
?
Linux CLI
cat < file.txt
A
Line1
Line2
BLine1\nLine2
CLine1 Line2
DError: invalid syntax
Attempts:
2 left
💡 Hint
Input redirection feeds the file content to the command as standard input.
🧠 Conceptual
expert
1:30remaining
How many lines will this command output?
You run the command cat fileA.txt fileB.txt | wc -l.

fileA.txt has 3 lines, fileB.txt has 5 lines.

What is the output number?
A3
B8
C5
D1
Attempts:
2 left
💡 Hint
The pipe sends combined output of both files to wc -l which counts lines.