linux_cat command

cat command can be used to display the contents of a text file (the command similar to the DOS type), the number of files may be attached to another content file, i.e. connected merge files.

About this command, some people think the cat command to write because people are like cats, so give this command named "cat", it is not true, cat is concatenate (connection, and continuous) shorthand.

Cat command basic format is as follows:

[root @ localhost ~] # cat [option] filename
or
[root @ localhost ~] # cat file1 file2> File 3

In both formats, the former is used to display the contents of the file, and a respective common options described in Table 1; and the latter is connected to the merged file.

Table 1 cat command commonly used options and meanings
Options meaning
-A Equivalent to the integration -vET option to list all the hidden symbols;
-E The end of each line are listed $ carriage;
-n All output lines are numbered;
-b With -n, this option indicates that only non-blank lines are numbered.
-T The Tab key ^ I displayed;
-V Lists the special characters;
-s When faced with two or more consecutive rows of empty rows, row replaces a blank line.


Note that when the cat command to view the contents of the file, regardless of how much the contents of the file will displayed at once. If the file is very large, so the beginning of the file contents will not see. But  Linux  can use the PgUp+上箭头key combination to page up, but this page there is a limit, if the file is long enough, you still can not see the whole content of the file.

Therefore, cat command is not suitable for viewing large files. Of course, in Linux can use other commands or methods to view the large files, we come to learn later.

[Example 1] The cat command itself is very simple, we can directly view the contents of the file. E.g:

[the root @ localhost ~] Anaconda-the ks.cfg CAT #
# File Automatically Generated by the Kickstart Anaconda.


# Version = DEVEL
the install
CDROM
lang ZH. 8-a CN.UTF
... ... omitted part

And if you use "-n" option will display line numbers. E.g:

[root@localhost ~]# cat -n anaconda-ks.cfg
1 # Kickstart file automatically generated by anaconda.
2
3
4 #version=DEVEL
5 install
6 cdrom
…省略部分内容...

If "-A" option is equivalent to using "-vET" option, the hidden symbols can view all the text, including the carriage return ($), the Tab key (^ I) and the like. E.g:

[root@localhost ~]# cat -A anaconda-ks.cfg
# Kickstart file automatically generated by anaconda.$
$
$
#version=DEVEL$
install$
cdrom$
…省略部分内容…


[Example 2] After the content files file1.txt combined and output to the file file3.txt in file2.txt.

[root@localhost base]# ls
file1.txt    file2.txt
[root@localhost base]# cat file1.txt
http://c.biancheng.net(file1.txt)
[root@localhost base]# cat file2.txt
is great(file2.txt)
[root@localhost base]# cat file1.txt file2.txt > file3.txt
[root@localhost base]# more file3.txt
#more 命令可查看文件中的内容
http://c.biancheng.net(file1.txt)
is great(file2.txt)
[root@localhost base]# ls
file1.txt    file2.txt    file3.txt

Guess you like

Origin www.cnblogs.com/vocoub/p/11707192.html