January 10, 2017, Tuesday Text Processing _ Division _ sorting _ statistics _ line compilationCompilation DeviceText file: tom:23:male:2013/05/06
Cut:-D: Specifies the field delimiter, which is the default space-F: Specify the fields to display-F 1,3-F 1-3
text sort: sort-N: Numeric sorting-R: Descending-T: Field delimiter-K: Which field is the keyword to sort-U: The same row is only displayed once after sorting-F: Ignore character capitalization when sorting
Text statistics: WC (word count)-L-W-C-L
sed basic usage:Sed:stream EDitorLine Editor (full screen Editor: VI)SED: Mode space By default does not edit the original file, only the data in the pattern space to do processing, and then, after processing, the mode space to print to the screen;
sed [options] ' addresscommand ' file ...-N: Silent mode, no longer displays the contents of the mode space by default-I: Modify the original file directly-E script-e script: Multiple scripts can be executed at the same time-f/path/to/sed_scriptSed-f/path/to/scripts File-r: Indicates the use of extended regular expressionsCommand:D: Delete the qualifying line;P: Displays rows that match the criteria;A \string: Appends a new line after the specified line, with the contents of string\ n: can be used for line wrappingI \string: Adds a new row before the specified line, with the contents of stringR file: Adds the contents of the specified file to the qualifying lineW File: Save the row in the range specified by the address to the specified file;s/pattern/string/modifier: Find and Replace, default replaces only the first string in each line that is matched to the patternAdd modifierG: Global SubstitutionI: Ignore character cases///: s###, [email protected]@@\ (\), \1, \2L.. E:like-->likerLove-->loverLike-->likeLove-->love&: Reference pattern matches entire string
SED exercise: 1. Remove the blank characters from the beginning of the/etc/grub.conf file; sed-r ' [Email protected]^[[:space:]][email protected]@g '/etc/grub.conf2, replace/etc/ The number in the "Id:3:initdefault:" line in the Inittab file is 5;sed ' [email protected]\ (id:\) [0-9]\ (: initdefault:\) @\15\[email protected] '/ ETC/INITTAB3, delete blank lines in/etc/inittab file; sed '/^$/d '/etc/inittab
Null
Text Processing _ Division _ sorting _ statistics _ Line Editor