File:/run/media/kiosk/ca9c-5ce5/11.11/11.5 (1) Page 1 of 3
Unit6. Text Processing tool *******
1.diff (diff files differ)
diff file File1/* Compare two different files
-c/* Show surrounding rows
-u/* Generate patches according to the same output
-R/* Compare the different files in two directories
Patch file File.path/* Patching
-B/* Back up the original file
***2.grep Regular expression (the row where the keyword is intercepted )
grep Key Character File | directory/* Find rows in a file or directory that contain keywords
Grep-i/* Ignore case
-N/* Display keywords in the row
-C/* Displays the number of filtered results
-V/* Reverse Filter
-e "keyword 1| keyword 2"/* Filter Multiple keywords
-R Directory/* Find files containing keywords in directory
Note: The ^ keyword/* starts with a keyword
Keyword $/* ends with a keyword
650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M00/8A/0C/wKiom1gkfU2igoJ7AAA6_Ho6oSY557.png "style=" float: none; "Title=" screenshot from 2016-11-08 21_24_13.png "alt=" Wkiom1gkfu2igoj7aaa6_ho6osy557.png "/>
650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M00/8A/08/wKioL1gkfU3hmNgPAABUs872Vnw500.png "style=" float: none; "Title=" screenshot from 2016-11-08 21_25_00.png "alt=" Wkiol1gkfu3hmngpaabus872vnw500.png "/>
650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M02/8A/08/wKioL1gkfU6RKml2AACMVgsXMTs249.png "style=" float: none; "Title=" screenshot from 2016-11-08 21_25_39.png "alt=" Wkiol1gkfu6rkml2aacmvgsxmts249.png "/>
3.cut (used to cut or display text segments in a file)
Cut/* intercept characters
cut-d delimiter/* Specify delimiter
Cut-f 1,7/* Displays the specified columns
Cut-c 1-4/* Displays specified characters
Ifconfig eth0 | grep inet | grep inet6-v | Cut-d ""-F 10
Ifconfig eth0 | grep inet | grep inet6-v | Awk-f "" ' {print $} '
4.sort/* Sort
Sort
-N/* Pure numeric sorting
-u/* Go redundant
|UNIQ-C/* Remove redundancy and count redundancy times
-k/* Specify column
-t/* Specify delimiter
5.uniq
Sort file |uniq-c/* Remove redundancy and count redundancy count
-d/* Show redundant rows
-u/* Displays unique rows
6.sed
Sed ' s/original character/replacement character/g ' file
Sed-e ' Strategy 1 '-e ' policy 2 ' file
Sed-i File/* Enter the converted content into the specified files
Sed ' 3,5s/original character/replacement character/g ' file/*3-5 line conversion
SED xd/* Mask specified line
Sed XP/* Copy the specified line
Sed-n XP/* Displays only specified lines
Sed-ne xp-ne YP File/* Specify to replicate 3 and 52 rows
Sed-n 3,5p File/* Copy 3-5 rows
Example: Sed-e ' s/^\ *//g ' file-e ' s/\t/\/g '-I file/* Replace the file with a space and start with the TAB key
A script (match the password to the account) *************
#!/bin/bash
max=$ (Wc-l $ | cut-d ""-F 1)/* Statistics number of rows for user
For NUM in $ (seq $MAX)/* Loop MAX times
Do
username=$ (sed-n ${num}p)/* Copy First-line
passwd=$ (sed-n ${num}p)/* Copy First-line
Useradd $USERNAME/* User add
echo $PASSWD | passwd--stdin $USERNAME/* This option is used to read the new password from the standard input pipe
Done
Unit6. Text Processing Tools