cat command

Concatenate (cat) is one of the most frequently used Linux command-line utilities. It is most commonly used to view the contents of a single file or concatenate the contents of multiple files that are not very long. It does not provide scroll-back functionality.

The following screenshot demonstrates utilization of cat command with single file:

The following screenshot demonstrates utilization of the cat command with multiple files:

We can perform multiple tasks using the cat command, as listed in the following table:

Command

Description

cat file1 file2

Concatenate file1 and file2 and display the output. The entire contents of file1 is followed by the contents of file2

cat file1 file2 > file3

Combine the contents of file1 and file2 and save the output into a new file, file3

cat demo1 >> demo2

Append the contents of the demo1 file to the end of the existing file, demo2

cat > demo

Any subsequent lines typed in the Terminal will go into the demo file, until Ctrl + D is pressed

cat >> demo

Any subsequent lines typed are appended to the demo file, until Ctrl + D is pressed

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.221.66.185