Cat Linux Commands
The Linux cat command is used to display file contents, for example if I quickly wanted to see the contents of a text file I would use the cat command to dump the output to the console or pipe it to another command.
Situations when the Linux cat command would used
- How To dump the contents of a file and pipe into another Linux command
- Show / display text files in Linux
- Display a text file with line numbers on Linux
- Redirect the output of a file into another file on the Linux command line
Linux cat Command Example 1
1
|
|
This would then display the entire contents of the file to the console, so for larger files you might want to pipe it through less or more:
Cat Command piped through less or more
1
|
|
If you only want to view the top of the file you might want to use the head command and likewise if you want view the bottom of a large file I would recommend using the tail command.
Cat Command Options
The cat command has the following options to allow more advanced functionality.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
|
Cat Command Install
How to install the cat command on RPM / DPKG based Linux systems.
Install Cat via YUM (CentOS, RHEL, Fedora)
If the cat command is missing on your RHEL based system (CentOS, RHEL, Fedora etc) then you can install it with the following YUM command:
1
|
|
Install Cat via APT (Debian, Ubuntu, Linux Mint)
To install cat on DPKG based distros, Ubuntu, Debian, Linux Mint etc enter the following command (on Mint & Ubuntu you will need to prefix with sudo).
1
|
|