cat Linux Commands

What is Linux cat Command?



cat linux command concatenates files and print it on the standard output.


cat [OPTIONS] [FILE]...


-A Show all.
-b Omits line numbers for blank space in the output.
-e A $ character will be printed at the end of each line prior to a new line.
-E Displays a $ (dollar sign) at the end of each line.
-n Line numbers for all the output lines.
-s If the output has multiple empty lines it replaces it with one empty line.
-T Displays the tab characters in the output.
-v Non-printing characters (with the exception of tabs, new-lines and form-feeds) are printed visibly.


  1. 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.
  2. 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).
  3. To display a file:

    This command displays the data in the file.
  4. 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.
  5. 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.

Ask Questions

Ask Question