Linux for Developers
/Beginner
cat
Definition
Concatenate. A command used to read data from a file and output its entire contents directly to the terminal screen.
Explain Like I'm New
The 'Print this file to the screen' command. It dumps all the text out at once.
Real World Example
You want to quickly check the IP address in a config file. You type `cat config.txt`. The text of the file is dumped onto your terminal screen so you can read it.
Common Use Cases
- •Reading small files
- •Combining (concatenating) multiple files into one
Crucial Command Flags
| Flag / Option | Description |
|---|---|
| -n | Number all output lines. |
| -b | Number non-empty output lines. |
| -E | Display $ at the end of each line. |
| -s | Squeeze multiple empty lines into one. |
Interview Questions
basic
- Why is it a bad idea to use `cat` on a massive 10GB log file?
intermediate
- How do you use `cat` to combine `file1.txt` and `file2.txt` into a brand new `file3.txt`?