The cat (short for concatenate) command in Linux is a very versatile and commonly used utility. It is primarily used to display the contents of a file, create single or multiple files, concatenate files, and redirect output in terminal or files. If you would like to view all the contents of a file in a Linux system cat is one of the commands that can help out, in this article we’ll show some basic usage of the Linux cat command.
Show the contents of a file
cat myFile.txt
Show contents of more than one file
cat myFile.txt myFile-2.txt
Write text into a newly created file
cat > fileThatWillBeCreated
then start typing. Once finished press Ctrl + D to exit
Display notifications that can assist
cat -n myFile.txt # Will display number lines cat -e myFile.txt # Will display $ at each line ending cat -T myFile.txt # Will display each tabulation with ^I
Remember that cat linux command is a powerful tool, and when used with other commands and redirection operators, it can serve a wide range of purposes in text processing and file manipulation.
Test your Linux knowledge on a Dedicated Server or an SSD VPS machine. Learn new Linux Commands or master your skills now!