The cat command is used to display the contents of a file in the terminal. Here’s how to use it:
Basic Usage
To display the contents of a file, use the following command:
cat filename.txt
Example
If you have a file named example.txt, you can view its contents by running:
cat example.txt
Redirecting Output
You can also redirect the output to another file using the > operator. For example, to save the contents of example.txt to a new file named output.txt, use:
cat example.txt > output.txt
Viewing Multiple Files
You can display the contents of multiple files at once:
cat file1.txt file2.txt
Adding Line Numbers
To display the contents with line numbers, use the -n option:
cat -n example.txt
These are some basic usages of the cat command. You can explore more options by checking the manual page with:
man cat
