0
0
Linux CLIscripting~5 mins

cat (display file contents) in Linux CLI - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What does the cat command do in Linux?
The cat command reads and displays the contents of a file on the screen. It can also combine multiple files into one output.
Click to reveal answer
beginner
How do you display the contents of a file named notes.txt using cat?
You type cat notes.txt in the terminal. This shows the full content of notes.txt on the screen.
Click to reveal answer
beginner
What happens if you use cat with multiple files like cat file1.txt file2.txt?
The contents of file1.txt and file2.txt are shown one after the other, combined in the output.
Click to reveal answer
intermediate
How can you create a new file using cat?
You can type cat > newfile.txt, then type your text. Press Ctrl+D to save and exit. This creates newfile.txt with your text.
Click to reveal answer
intermediate
What is a simple way to number the lines of a file when displaying it with cat?
Use cat -n filename. This shows the file content with line numbers before each line.
Click to reveal answer
What does the command cat file.txt do?
ARenames file.txt
BDeletes file.txt
CCopies file.txt
DDisplays the content of file.txt
How do you combine two files a.txt and b.txt into one output using cat?
Acat a.txt b.txt
Bcat a.txt + b.txt
Ccat -c a.txt b.txt
Dcat --merge a.txt b.txt
Which key combination do you press to finish typing text when creating a file with cat > file.txt?
ACtrl+D
BCtrl+Z
CCtrl+C
DCtrl+X
What does cat -n file.txt do?
ACounts words in file.txt
BDeletes file.txt
CDisplays file.txt with line numbers
DCopies file.txt
If you want to quickly view a file's content, which command is best?
Atouch filename
Bcat filename
Cmkdir filename
Drm filename
Explain how to use cat to display a file and how to combine multiple files into one output.
Think about how you read one book page and then two books back to back.
You got /3 concepts.
    Describe the steps to create a new text file using cat and how to save it.
    Imagine writing a note and then closing the notebook to save it.
    You got /3 concepts.