The Linux cat command parameters and method of use.

Recommended for you: Get network issues from WhatsUp Gold. Not end users.

Cat is a Linux system used to view the file contents in continuous instruction, literally meaning is “ concatenate” (continuous) abbreviation. In addition to used to display the contents of a file, the cat command can also be used for standard processing flow, such as the display of information to another file or additional.

The command format
Cat [options] [file]...

The command function
Cat has three main functions:
Display the entire file at a time: cat filename
Create a file from the keyboard: cat > filename can only create a new file, cannot edit existing files.
Several files into one file: cat file1 File2 > file

The command parameter
-n or --number on all the output line numbers, and from 1 to all output line numbers
-b or --number-nonblank  and -n is similar, but the blank line is not numbered
-s or --squeeze-blank  when there is a blank line for two more lines, as substitution for a blank line
-v or --show-nonprinting ^ and M- references, in addition to LFD and TAB

The example
Example: the contents of the file and line number linuxeye.css input after the linux.css in this file
cat -n linuxeye.css > linux.css

Example two: the file contents of file1.txt and file2.txt with line numbers (blank lines without) the content added to the file3.txt.
cat -b file1.txt file2.txt > file3.txt

Example three: cat and EOF
EOF is “ end of file&rdquo, said the end of text character;.
The combination of these two signs, to avoid the use of multi line echo command mode, and realizes the multi line of the output results.
# cat > linuxeye.txt <<EOF
> Hello
> Linuxeye
# ls -l linuxeye.txt
-rw-r--r-- 1 root root 32 Jun  5 18:43 linuxeye.txt
# cat linuxeye.txt

TAC (reverse line display)
# echo -e "1111\n22222\n345678" > tac.txt
# tac tac.txt
TAC is a cat write back over, so his function as cat in contrast, cat is composed of the first row to the last row continuously displayed on the screen, while the TAC is displayed on the screen by the last row to the first reverseļ¼

Reprint please keep the link

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download

Posted by Morton at November 09, 2013 - 10:16 AM