Javatpoint Logo
Javatpoint Logo

Linux cat command (to concatenate)

The 'cat' command can be used to concatenate contents of multiple files in a single new file.

Syntax:

Example:

Linux cat concatenate1

Look at the above snapshot, we have combined three files "file1, file2, and file3" into a single file "combo" with the command "cat file1 file2 file3 >combo".

Notice the content of three separate files and then the content of new concatenated file that is "combo".

To Insert A New Line

A new line will be inserted while concatenating multiple files by using hyphen (-).

syntax:

Example:

Linux cat concatenate2

In the above snapshot, we have inserted a new line at the beginning while concatenating file1, file2 and file3 with the command "cat ? file1 file2 file3 >combo".

Note: Line will be inserted at the beginning of the file only.





Please Share

facebook twitter google plus pinterest

Learn Latest Tutorials


B.Tech / MCA