cat (Concatenate)
Explanation
The cat command is one of the most frequently used commands in Linux. It reads files sequentially, writing them to standard output. It's commonly used to view the contents of short files, combine multiple files into one, or create new files.
Basic Syntax
cat [OPTION]... [FILE]...
Common Flags and Options
| Flag | Description |
|---|---|
-n, --number | Number all output lines. |
-b, --number-nonblank | Number nonempty output lines, overrides -n. |
-E, --show-ends | Display $ at end of each line. |
-T, --show-tabs | Display TAB characters as ^I. |
Real-world Examples
-
View the contents of a file:
cat file.txt -
Concatenate two files into a new file:
cat file1.txt file2.txt > newfile.txt -
Append the contents of one file to another:
cat new_data.txt >> existing_file.txt