*****************6. File Command ********************
## 1.diff # #
diff file File1 // Compare two different files
-c //display different rows
-u //generate patches According to unified format Unified output
-r //comparing files in two directories
Patches File File.patch //patch
-B //backing up the original file
650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M01/89/FD/wKiom1gi_6LQSGI6AADhf5wU-Vg773.png "style=" float: none; "title=" capture. PNG "alt=" Wkiom1gi_6lqsgi6aadhf5wu-vg773.png "/>
650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M02/89/FD/wKiom1gi_6PyCZ2fAADslq8zfTk463.png "style=" float: none; "Title=" Captures 1png.png "alt=" Wkiom1gi_6pycz2faadslq8zftk463.png "/>
## 2.grep # #
grep key character File | Directory //find rows in a file or directory that contain keywords
grep -i //Ignoring case
-c //display the number of filtered results
-v //Reverse Filter
-e //"keyword 1| keyword 2" Filter multiple keywords
-r catalog //Find files with keywords in the directory
Note: ^ keywords //
keywords starting with a keyword $ //
at the end of the keyword
Example: Searching for a row with root in the passwd file and ignoring the case
650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M01/89/FA/wKioL1gjAHSDGF73AAAxST6kYZs114.png "style=" float: none; "title=" capture. PNG "alt=" Wkiol1gjahsdgf73aaaxst6kyzs114.png "/>
Searches the passwd file for the row containing the root and displays the line number
650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M02/89/FD/wKiom1gjAHSQ7jmkAAAm-tkZK7A618.png "style=" float: none; "Title=" Captures 1. PNG "alt=" Wkiom1gjahsq7jmkaaam-tkzk7a618.png "/>
Count the number of rows in the passwd file that contain root
650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M00/89/FA/wKioL1gjAHTweVEfAAAJarRiOXo867.png "style=" float: none; "Title=" Captures 3. PNG "alt=" Wkiol1gjahtwevefaaajarrioxo867.png "/>
Searches the passwd file for the row containing the root and the root is not in the beginning
650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M02/89/FA/wKioL1gjAHWzl-QuAAAZP5-5THg051.png "style=" float: none; "Title=" Captures 4. PNG "alt=" Wkiol1gjahwzl-quaaazp5-5thg051.png "/>
Search the passwd file for rows that contain root or student
650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M01/89/FD/wKiom1gjAHbhQExaAAAgUHmRs1I546.png "style=" float: none; "Title=" captures 5. PNG "alt=" Wkiom1gjahbhqexaaaaguhmrs1i546.png "/>
Search for root-containing files in/mnt
650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M01/89/FA/wKioL1gjAHegW0AgAAAx36Jiszg703.png "style=" float: none; "Title=" captures 6. PNG "alt=" Wkiol1gjahegw0agaaax36jiszg703.png "/>
# # 3.sort # # Sort
Sort-n//Pure Digital sorting
-U//Remove Redundancy
-t//Specify Separator
-k//Specify column
|UNIQ-C//Remove redundancy and count the number of redundancies
|UNIQ-D//Display redundant rows
|uniq-u//Show unique rows
Example: Sorting file files with pure numbers and removing redundancy
650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M00/89/FD/wKiom1gjAe7QeW_5AAAPddxtwHA219.png "title=" capture. PNG "style=" Float:none; "alt=" Wkiom1gjae7qew_5aaapddxtwha219.png "/>
Sort the file files purely digitally and remove redundancy and count redundancy
650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M00/89/FD/wKiom1gjAe7wJewGAAASEL6yw0U179.png "title=" Capture 1. PNG "style=" Float:none; "alt=" Wkiom1gjae7wjewgaaasel6yw0u179.png "/>
Sort the second column as a delimiter by using the file with:
650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M00/89/FA/wKioL1gjAe7S5rHpAAAT5jrA6s0999.png "title=" Capture 2. PNG "style=" Float:none; "alt=" Wkiol1gjae7s5rhpaaat5jra6s0999.png "/>
To display the second column of redundant rows as delimiters for file files:
650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M02/89/FA/wKioL1gjAe2A_Gq-AAASV17P2lc550.png "style=" float: none; "title=" 4.PNG "alt=" Wkiol1gjae2a_gq-aaasv17p2lc550.png "/>
To the file file with: As a delimiter for the second column to do a pure numeric sort remove redundancy and count redundancy
650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M00/89/FA/wKioL1gjAe-D22zyAAAlzwr4qaQ499.png "style=" float: none; "Title=" Captures 3. PNG "alt=" Wkiol1gjae-d22zyaaalzwr4qaq499.png "/>
Show second column unique row to file with: as delimiter
650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M01/89/FD/wKiom1gjAfDBnRnUAAAe8ko5584276.png "style=" float: none; "Title=" captures 5. PNG "alt=" Wkiom1gjafdbnrnuaaae8ko5584276.png "/>
# 4.cut # #
cut // intercept character
-d Separators //Specifies the delimiter
-C 1-4//display specified characters
# 5 . Sed # #
Tr ' A-Z ' A-z ' file//Convert case
Sed ' s/original character/replacement character/g ' File//Replace
-E ' policy 1 '-e ' policy 2 ' file//Multiple policy substitution
-I file//convert the converted content to the specified file
' 3,5s/original character/replacement character/g ' file//convert 3-5 lines
5d File//Mask line Fifth
5p file//copy line fifth
-N 5p file//Show only line fifth
Example: Converting all passwd files to uppercase
650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M02/89/FD/wKiom1gjBLWQLgclAAA9Xp6NX-s775.png "style=" float: none; "title=" capture. PNG "alt=" Wkiom1gjblwqlgclaaa9xp6nx-s775.png "/>
Example: Replace the root of passwd full text with student
650) this.width=650; "src=" Http://s2.51cto.com/wyfs02/M00/89/FA/wKioL1gjBLajAGqkAAB_eeTNQwM811.png "style=" float: none; "Title=" Captures 1. PNG "alt=" Wkiol1gjblajagqkaab_eetnqwm811.png "/>
Example: Replace the root of passwd full-text with student and replace all mail with Hello
650) this.width=650; "src=" Http://s2.51cto.com/wyfs02/M02/89/FA/wKioL1gjBLfD75cNAACKa8e7Oiw024.png "style=" float: none; "Title=" Captures 2. PNG "alt=" Wkiol1gjblfd75cnaacka8e7oiw024.png "/>
Example: Replace passwd's 3-5-line nologin with Root
650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M00/89/FA/wKioL1gjBLjgBYQ9AAB4j6YMcVw463.png "title=" Capture 4. PNG "style=" Float:none; "alt=" Wkiol1gjbljgbyq9aab4j6ymcvw463.png "/>
Example: View the passwd file and copy line fifth
650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M02/89/FA/wKioL1gjBbDRFtFrAABtob37zog507.png "style=" float: none; "Title=" captures 6. PNG "alt=" Wkiol1gjbbdrftfraabtob37zog507.png "/>
Example: Viewing the passwd file shows only line fifth
650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M00/89/FA/wKioL1gjBbXhiJpTAAAb-uxsxxQ609.png "title=" Capture 8. PNG "style=" Float:none; "alt=" Wkiol1gjbbxhijptaaab-uxsxxq609.png "/>
# 6.awk # #
awk ' {pattern + action} ' {filenames}
Pattern represents what AWK looks for in the data, and the action is a series of commands that are executed when a match is found.
Practice, existing two files put the user name and user password of the user to be created separately
Create these users using scripts
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/89/FD/wKiom1gjBbbRkPIeAABWL9Lorec878.png "title=" Capture 9. PNG "style=" Float:none; "alt=" Wkiom1gjbbbrkpieaabwl9lorec878.png "/>
Linux Note 2-6 file commands