Networking/Computing Tips/Tricks

The 'cat' [short for “concatenate“] command is one of the most frequently used commands in Linux and other operating systems. The cat command allows us to create single or multiple files, view contain of file, concatenate files and redirect output in terminal or files.

The command is available in Linux, Windows Power Shell, and MAC-OS.

Here is the Windows usage screen for cat:


Here is a Linux cat help screen:


We understand there are lots of options, now let's look at some usage examples.

1. The most basic and repetitive use of cat is to display the contents of a file.  If you are using Linux, the following example will show contents of /etc/passwd file:

# cat /etc/passwd


2. You can use cat to create a simple file.  Let's create a file called 'example1':

# cat >example1

Now simply enter the information you want in the file followed by the CTRL+D (hold down Ctrl Key and type ‘d‘) to exit. The information you typed will be written into the example1 file.


You can verify this using the following command:

# cat example1


3. We can take that a step further and view content of multiple files where 'example1' and 'example2' are files:

# cat example1 example2


4. Another way to display multiple files is to use the ';' between cat commands:

# cat example1; cat example2; cat example3


5. Sometimes the output of displaying a file runs off the screen.  Managing how much information the cat command displays is simple.  The cat command comes with the ability to control the screen output with 'more' or 'less':

# cat bigfile.txt | more


One screen worth of the file will be shown at a time with the "More" word at the bottom.  Just hit the space bar to display the next screen.

# cat bigfile.txt | less

This time the ":" will be displayed.  Just hit 'Q' to quit.

6. In the old days, line numbering was important in programming.  Today, sometimes when helping someone find a particular item, it is helpful to have line numbers in the display.  The cat command can use the '-n' option to display line numbers:

# cat -n bigfile.txt


7. You can use cat to redirect output from the terminal window (default output) to say another file.  This is called the redirection operator.  This is done with the ‘>‘ (greater than) symbol. Be careful here, as you may overwrite an existing file!!

# cat example1 > example3

Essentially we have created a copy of example1 in example3.

8. OK - so what is we had an existing example3 file and we wanted to append example1 contents onto example3?  The cat command supports this with the ‘>>‘ (double greater than) symbol. 

# cat example1 >> example3

9. Taking that a step further, what is we wanted to send contents of multiple files and create a single file?  The cat command does this as follows:

# cat example1 example2 example3 > example4

These files are added in order.

10. Taking that process even further, what if we wanted to do the same thing as #9 but this time sort the contents?  The cat command can do this easily with piping to the 'sort' process:

# cat example1 example2 example3 | sort > example4

11. OK - what if we wanted to create a file with some set of commands we use regularly and that as input?  The cat command does this with the ‘<‘ (less than symbol):

# cat < example5


Great stuff.  We hope we have you off and running with the cat command.  We certainly did not cover every option, and encourage you to learn more about this powerful little command. 

What other uses of the cat command would you add to our list?  Add a comment below!

Comments powered by CComment

The nicest thing you can do is use these inks to support us!  Thank you!

Support our research!  Buy me a coffee :)

Support our research. Become a Patron!

Find by Tag

4G Networks 5G Networks 6in4 6LoWLAN 6LoWPAN 802.11 802.11ah 802.11ax 802.11ay 802.11az Addressing Analysis Ansible Architecture ARP AToM BGP Bloom's Taxonomy Broadband Cable cat CBRS CellStream Cellular Central Office Cheat Sheet Chrome Cisco Cloud Coloring Rules Computer Consulting CPI Customer Support Data Center Data Networking DHCPv6 DNS Docker Documentation Dublin-Traceroute dumpcap ECMP Ethernet Ethics Fragmentation G-MPLS Git GNS3 Google GQUIC Hands-On History Home Network ICMP ICMPv6 IEEE 802.11p IEEE 802.15.4 Interface Control Internet IoT IPsec IPv4 IPv6 IS-IS L2VPN L3VPN LDP Linux LLN LoL M-BGP MAC MAC OSx Macro Microsoft mininet Monitoring MPLS MTU Multicast My Room Name Resolution Netcat Netmiko NetMon netsh Networking Network Science nmap Npcap Online School OpenFlow OSPF OSPFv2 OSPFv3 OSX OTT Paris-Traceroute Parrot PIM pktmon PMTU Policy POTS POTS to Pipes PPP Profile Programming Project Management Protocol 41 PW3E Python QoS QUIC Remote Desktop Requirements RIP Routing RPL RSVP Rural SAS SDN Security Service Provider Small Business SONET Speed SS7 SSH SSL Subnetting SYSCTL T-Shark TCP TCP/IP Telco Telecom 101 Telecommunications Telephone termshark TLS Tools Traceroute Traffic Engineering Training Travel Tunnel Ubuntu Utility Video Virtualbox Virtualization VoIP VRF VXLAN Webex WEP Wi-Fi Wi-Fi 4 Wi-Fi 5 Wi-Fi 6 Wi-Fi 6/6E Windows Winpcap Wireless Wireless 5G Wireshark Wireshark Tip WLAN WPA2 Zenmap ZigBee Zoom

Support us by clicking:

Twitter Feed