Mind Mapping:
For the regular expression and file format processing has done the following map, to make a general overview of it, the bottom of which is described in turn.
Regular ExpressionsEncyclopedia Explanation:
A regular expression is a logical formula for the operation of a string of characters, which is a " rule string "that is made up of a predefined set of characters, and a combination of those specific characters , which a " rule string " is used to express a filtering logic for a string.
Objective:
1 . Whether the given string conforms to the filtering logic of the regular expression (called "Match");
2 . You can get the specific part we want from the string through a regular expression.
3 . Complex control of strings can be achieved quickly and in a very simple way.
command:
I have divided the commands of the regular expression into the basic and the extended two parts.
Base:
base has lookup (grep) and modify (Set) two items;grepthe lookup has:1,.represents an arbitrary character. 2,^with the&represents the beginning and end of a line. 3,/<with the/>represents the beginning and end of a matching word, respectively. 4,*represents the first character repeating 0 to infinity (the difference between note and wildcard characters). 5,[List]to find the character you want to select,Listlists the possible character sets that the string contains. It can also be extended to:[N1-N2]and the[^list], for[N1-N2]which-represents a range, fromN1to theN2, for[^list]Express meaning with[List]instead. 6, String Rules: string rules haveXz\{n\}y,Xz\{n,m\}yand theXz\{n,\}yand so on, respectively, said:xand theybetween thereNaZthe characters,xand theybetween thereNto themaZthe characters,xand theybetween thereNto an infiniteZthe character. ForSetThe changes are:1, withDcharacters are used to represent deletions, such as:Set'1,2d'hostsand WillhostsDelete the file for the row. 2, withscharacters are used to represent substitution functions, such as:Set's/root/root/g'xx, indicating that thexxall of theRootreplaced byROOT,srepresents a replacement.
Extensions:
for an extended regular expression, there are:1,+means to repeat one or more of theREcharacters. 2,? Represents the first of 0 or oneREcharacters. 3,|represents the use or method of finding a string. 4, () represents a string of characters in parentheses that are written to find the duplicate content of a string, divided by or related to the strings. 5, ()+Represents a group of multiple groups of characters.
file ProcessingObjective:
It is used to make a simple arrangement of the files, or to compose the information you need.
in the process of file processing, I have three parts, namely: 1 , printf , awk and file comparisons.
Printf:
you can format your data for output. It can add related parameters, for the meaning of parameters can find manpage or help files to learn and apply.
Awk:
1, basic usage:awk-fdelimiter ' condition{Operation}' file, which is used to perform the appropriate operation on the file. 2, add line number: in{}within thePrintafter operation, addNR. 3, plus field count: in{}inside the last plusNF. 4, output format processing: withOFSindicates a separator between fields, withORSindicates a separator between rows.
file Comparison:
1.diff: Compare the size of files or directories or other differences. 2, the same for file comparison, in the diff difference is that it uses byte units to compare. 3,patch: Through file comparison, mainly used for upgrading and patching and other purposes. Only the different parts are processed.
General statement:
This is a small summary of the formatting and processing of regular expressions and files that I have learned, about regular expressions to pay attention to and wildcard characters to distinguish, they are completely different two content, it is easy to confuse, and then there is a lot of knowledge about regular expressions, this is only a preliminary understanding, in the future learning also need to be constantly updated.
Learn about Linux with Bird's--Regular expressions and file format processing