cat Linux Commands
What is Linux cat Command?
cat COMMAND:cat linux command concatenates files and print it on the standard output.
cat [OPTIONS] [FILE]...
||Omits line numbers for blank space in the output.
||A $ character will be printed at the end of each line prior to a new line.
||Displays a $ (dollar sign) at the end of each line.
||Line numbers for all the output lines.
||If the output has multiple empty lines it replaces it with one empty line.
||Displays the tab characters in the output.
||Non-printing characters (with the exception of tabs, new-lines and form-feeds) are printed visibly.
- To Create a new file:
This command creates a new file file1.txt. After typing into the file press control+d (^d) simultaneously to end the file.
- To Append data into the file:
To append data into the same file use append operator >> to write into the file, else the file will be
overwritten (i.e., all of its contents will be erased).
- To display a file:
This command displays the data in the file.
- To concatenate several files and display:
The above cat command will concatenate the two files (file1.txt and file2.txt) and it will display the output in the screen.
Some times the output may not fit the monitor screen. In such situation you can print those files in a new file or
display the file using less command.
- To concatenate several files and to transfer the output to another file.
In the above example the output is redirected to new file file3.txt. The cat command will create new file file3.txt and store the concatenated output into file3.txt.