DIFF
Role
The DIFF command is used for comparison between two files and points out that the two are different, and its use allowance is all users.
2. Format
DIFF [Options] Source File Target File
3. [Options] Main parameters
-a: Processing all files as a text file.
-b: Ignore the difference in space.
-B: Ignore the difference between empty lines.
-c: Use the outline output format.
-H: Use the test method to accelerate the search for large files.
-I: Ignore changes in cases.
-n --rcs: Output RCS format.
CMP
Role
The CMP ("Compare" abbreviation) The command is used to briefly indicate whether there is a difference in two files, and its use permissions are all users.
2. Format
CMP [Options] file name
3. [Options] Main parameters
-l: The byte is output in decimal manner and is convenient to output different eight-in-one ways in both files.
Cat
Role
The CAT ("Concatenate" command is used to connect and display information about the specified one and multiple files, which is all users.
2. Format
CAT [options] file 1 file 2 ......
3. [Options] Main parameters
-N: The number of line numbers to all outputs is started by the first row.
-B: and -n are similar, but it is not numbered for blank lines.
-S: When there is a blank row with two consecutive lines, it is changed to a blank line of a line.
4. Application example
(1) CAT command A simplest use is the content displaying text files. For example, we want to see the contents of the Readme file in the command line, you can use the command:
$ Cat Readme
(2) Sometimes several files are processed into a file and save the results of this processing to a separate output file. The CAT command accepts one or more files on its input and prints them as a separate file to its output. For example, after adding the contents of ReadMe and Install, the content is attached to a new text file file1:
$ Cat Readme Install File1
(3) There is also an important function of CAT to numbered on the line, see Figure 2. This feature is for program documents, as well as the preparation of legal and scientific documents, printing the line number on the left makes a part of the reference document becomes easy, these are programming, scientific research, business reports, even legislative work is very important.
Figure 2 is numbered using the CAT command /etc/named.conf file
The number of lines is performed with -b (only numbered non-blank lines) and -n (you can numbered all rows):
$ cat -b /etc/named.conf
ln
Role
The ln command is used to create a link between files, and its use allowance is all users.
2. Format
LN [options] Source File [Link Name]
3. Parameters
-F: Delete the source file before the link.
-D: Allows system managers hard link to their own directory.
-S: Symbolic Link.
-B: The file that will be overwritten or deleted during the link.
There are two links, one is called hard link, and the other is called a symbolic link. By default, the ln command produces a hard link.
The hard connection refers to the connection through an index node. In Linux's file system, the file saved in the disk partition is no matter what type is assigned a number, called the index node (inode index). In Linux, multiple file names are existing to the same index node. Generally, this connection is hard connection. The hard connection is to allow a file to have multiple valid path names so that users can establish a hard connection to important files to prevent "erroneous deletion". The reason is as described above because there is more than one connection to the index node that should be directed. Only delete a connection does not affect the index node itself and other connections, only when the last connection is deleted, the file data block and directory connection will be released. That is, the file will be truly deleted. Corresponding to the hard connection, another connection is still in the LNUX system, called symbilc link, is also a soft connection. Soft link file is a bit similar to Windows shortcuts. It is actually a special file. In the symbol connection, the file is actually a text file, which contains location information with another file.
Handicap
Above we introduced the Linux file processing command, introduce several instances below, you can practice the command you just said.
1. Using symbolic links to quickly access key directory
The symbolic link is a very useful feature. Suppose some directory or files need to be used frequently, but this file or directory is in a deep subdirectory due to Linux files and directory structures. For example, the Apache Web Server Document is in the system / usr / local / httpd / htdocs, and does not want each time you have to enter such a long path every time (actually, this path is also very difficult to memorize).
To solve this problem, you can create a symbolic link in the primary directory so you can enter this link when you need to enter the directory.
In order to facilitate access to the directory where the web server (/ usr / local / httpd / htdocs) document is located, you can use the following command in the home directory:
$ ln -s / usr / local / httpd / htdocs gg
This way to access the web server each time you enters the GG directory. If you no longer access the document of the web server, you can delete the GG, and the real web server's documentation is not deleted.
2. Import Init.rd format root.ram content using the DD command
DD if = / dev / fd0 of = floppy.fd
DD if = root.ram of = / dev / ram0 #
3.GRep Command System Call
GREP is one of the most widely used commands in Linux / Unix, and there are many Linux systems to call it.
(1) If you want to query the directory in the list of directory, the method is as follows:
$ ls -l | grep '∧d'
(2) If all files that do not contain directories are queried in a directory, the methods are as follows:
$ ls -l | grep '∧ [∧D]'
(3) Call the GREP with the FIND command, such as "chinput" in all C source code, the method is as follows:
$ FIND / ZHXWIN -NAME * .c -exec grep -q -s chinput {} /; - print