Skip to content

Phils Blog and Stuff

TELECOMS. VIRTUALIZATION. IT. CODING. and more…

Menu
  • Home
  • Resources
    • Subnet Mask Cheat Sheet
    • Easy Dmarc+Email
    • MX Tool Box
    • LOAD BALANCING & SRE
  • SHOP
  • SOLUTIONS
  • SERVICES
  • Contact Me
Menu

Cat Linux Command

Posted on 23/10/201208/03/2023 by Phil

The cat Linux 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.

Linux Cat Command

Situations when the cat Linux 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

cat blah.txt

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

cat blah.txt | less

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.

       -A, --show-all
              equivalent to -vET

       -b, --number-nonblank
              number nonempty output lines

       -e     equivalent to -vE

       -E, --show-ends
              display $ at end of each line

       -n, --number
              number all output lines (handy for script parsing) 

       -s, --squeeze-blank
              suppress repeated empty output lines

       -t     equivalent to -vT

       -T, --show-tabs
              display TAB characters as ^I

       -u     (ignored)

       -v, --show-nonprinting
              use ^ and M- notation, except for LFD and TAB

       --help display this help message and exit

       --version
              show cat version information and exit

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:

yum install coreutils

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).

apt-get install coreutils

POSTS

  • Home Assistant. Add water meter with PHP+MQTT+YML.
  • Automating your home with Home Assistant. Initial install and config (Hyper-V).
  • The importance of setting up email security correctly.
  • Automate Debian installations with Seed, DHCP and Nginx.
  • A simple link shortener.. Fun little project…

WORD CLOUD

3CX 3CX Phone System Apache Asterisk Cacti CentOS CRM DHCP DNS Email Fail over Failover File System Firewall FreeBSD FreeNAS FXO IAX install IP IP PBX Linux M0n0wall Nottingham Open Source PBX PFSense PHP Router Server SIP snom SSH TrixBox ubuntu VLAN Voice VoIP VPN vyatta WAN Website WiFi yealink ZFS

© 2025 Phils Blog and Stuff | Powered by Superbs Personal Blog theme