cat
cat
stands for concatenate and print files. It is an extremely useful tool that prints the entire contents of a file to standard output, by default. For example, to print the contents of a text file called myfile.txt
.
cat /home/john/myfile.txt
Output
Hi! This is the text of /home/john/myfile.txt
cat
is particularly useful when we want to quickly check to see what is inside of a file. If, however, the file you are cat
-ing is a very large file, a tool like less
may be a better choice, as you can peek at the file and scroll in an efficient way, without dumping the entire contents.
cat
is commonly used to output the contents of a file and then pipe it to another tool, for data analysis, for example, that may not natively support reading from a file.