Viewing Text File Content
The cat command allows you to read /view the contents of the text files without editing them. The easiest method of reading a file is to use the cat command followed by the filename, as shown in the example below:
Moving Through Long Text Files
You can also append less to the cat command using a pipe (|), in order to check the file page by page.
See the below example with the marked colon, indicating that you can scroll up and down.
cat logfile.txt | less
Using cat Command to Redirect and Save
It is also possible to save the output contents of the cat command in a file. To do this, simply type cat followed by an output redirection operator.
cat /proc/cpuinfo > /root/cpu-information.txt
The cat command can also be used to read multiple files at the same time. If you want to combine and read multiple files, you can use the example below.
cat myfile1.txt myfile2.txt myfile3.txt
You can also redirect the combined output to a new file as shown in the example below.
cat myfile1.txt myfile2.txt myfile3.txt > newfile.txt