There are three main features of the Linux Cat command:
The 1,cat command displays the entire file at once.
$ cat FileName
The 2,cat command creates a file from the keyboard.
$ cat > FileName
Only new files can be created and existing files cannot be edited.
The 3,cat command merges several files into one file.
$ cat file1 file2 > file
Parameters:
-N or--number the number of rows for all outputs starting from 1
-B or--number-nonblank and-n similar, except for blank lines not numbered
-S or--squeeze-blank
A blank line that is substituted for a row when it encounters a blank line that has more than two consecutive lines
-V or--show-nonprinting
Example:
Cat-n textfile1 > Textfile2 textfile1
The file, add the line number and enter the Textfile2 file.
Cat-b textfile1 textfile2 >> Textfile3 put Textfile1 and
Textfile2 the contents of the file plus the line number (blank line not added) after attaching the content to the
In the Textfile3.
Example:
Add a line number to the Textfile1 file and enter the Textfile2 file.
Cat-n textfile1 > Textfile2
Put Textfile1 and Textfile2
The contents of the file are appended to the TEXTFILE3 after adding the line number (blank line not added)
In
Cat-b textfile1 textfile2 >> textfile3
Cat/dev/null >/etc/test.txt
This is to empty the/etc/test.txt archive content