Networking/Computing Tips/Tricks

Rate this content:
3 of 5 - 7 votes
Thank you for rating this article.

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 to the terminal or to 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!

I hope you find this article and its content helpful.  Comments are welcomed below.  If you would like to see more articles like this, please support us by clicking the patron link where you will receive free bonus access to courses and more, or simply buying us a cup of coffee!, and all comments are welcome! 

Add comment


Did you learn something?
Did I save you time? 

Buy me a coffeeBuy me a coffee!

Find by Tag

5G Networks 6LoWLAN 6LoWPAN 802.11 802.11ah 802.11ax 802.11ay 802.11az ACL Addressing Analysis Ansible Architecture ARP Assessment AToM Backup Bandwidth BGP Bibliography Biography Briefings CBRS CellStream Cellular Central Office Cheat Sheet Chrome Cisco Clock Cloud Computer Consulting CPI Data Center Data Networking Decryption DHCPv4 DHCPv6 Display Filter DNS Documentation ECMP EIGRP Ethernet Flipping the Certification Model Follow Me Fragmentation Git GNS3 Google GQUIC Hands-On History Home Network HTTPS ICMP ICMPv6 IEEE 802.11p IEEE 802.15.4 In A Day Internet IOS Classic IoT IPv4 IPv6 L2 Switch L2VPN L3VPN LDP Learning Services Linux LLN Logging LoL M-BGP MAC MAC OSx Macro Microsoft mininet Monitoring Monitor Mode MPLS Multicast Name Resolution Netflow NetMon netsh Networking Network Science nmap Npcap nslookup Online Learning Online School OpenFlow OSPF OSPFv2 OSPFv3 OSX Parrot pcap pcap-ng PIM Ping Policy POTS POTS to Pipes PPP Profile Profiles Programming Project Management Python QoS QUIC Requirements RFC RIP Routing RPL RSVP Rural SAS SDN Security Self Certification Service Provider Sharepoint Small Business Smartport SONET SSH SSL Subnetting T-Shark TCP TCP/IP Telco Telecom 101 Telecommunications Telephone Telnet Terminal TLS Tools Traceroute Traffic Analysis Traffic Engineering Training Travel Troubleshooting Tunnel Utility Video Virtualbox Virtualization Voice VoIP VXLAN Webex Wi-Fi Wi-Fi 4 Wi-Fi 5 Wi-Fi 6 Wi-Fi 6/6E Windows Wireless Wireless 5G Wireshark Wireshark Tip WLAN ZigBee Zoom

Twitter Feed