Several commands from the terminal
Search for characters in files:
Grep + character + file nameCopy the code
After searching for characters in the file, scroll down 3 lines (up 3 lines is -b)
Grep + character + file name -a 3Copy the code
Grep is case sensitive by default. If you do not want to be case sensitive, add -i after it
Grep + character + file name -a 3 -iCopy the code
Search for all characters except a character:
Grep -v + character + file name -a 3 -iCopy the code
Search only for characters followed by an S
Grep + character + [s] + file nameCopy the code
Search only for characters that are not followed by an S
Grep + character + [^s] + file nameCopy the code
To search the contents of a file with a re:
Grep + regular expression + file nameCopy the code
Enable extended regular expressions:
Grep + -e + regular expression + file nameCopy the code
Echo “character” | grep “regular expressions”
It will use the re to match the preceding character, and then output the match
Search for a line with a character: you can use the anchor operator
Exercise 1:
Assuming egrep ‘(fooq | foo) * (qbarquux | bar)’ analysis of the string is:
A.fooqbarquux B. Fooqbar C
Answer: C
- (fooq | foo) : grouping operator, can be a fooq can also be foo begins
- * : repeat operator, can be 0 or more times
- (qbarquux | bar) : grouping operators, end can be qbarquux or bar
Suppose the string parsed by egrep ‘((a*)b)*\1\2’ is
A.aabababa B.aabaabaabaabaa C. None of the above
Answer: B
- (a *) : a can be repeated once or many times - (a *) b: on behalf of a can be multiple, but only a - b (b) (a *) * : on behalf of the inside of the parentheses can be multiple grouping - if more than one match (for example, followed by repeat operator, namely \ *), the backward quoted strings that will be grouped the last match, So "\1" = aa, "\2" = emptyCopy the code
Assuming egrep ‘(one (x) | two (y)) – and – (three \ | 2 four \ 3) the string is’ analysis
A.onex-and-threex B.twoy-and-foury C.onex-and-four D.twoy-and-threey E.twoy-and-threex F. None of that is true
Answer: AB
- (one (x) | two (y)) : group 1 - (x) : group 2 - (y) : A set of 3 - A: match the one in front of the, so x = x \ 2 = x, so A correct - B: matching the two front, so, y = y \ 3 = y, so B is correctCopy the code
Match the character string “License:”Creativecommons.org/licenses/by…
The answer:
- full version: (license) [:] (\ s *) [" ": /, \ % - A - Za - z0-9] \ * - license at the beginning, followed by:, then repeat 0 - n Spaces, then contains all kinds of characters n cycle - the concise version: (License)(.*) - (.*): matches all characters except newline charactersCopy the code
Breakpoints a function in the specified library that matches the specified regular expression
(LLDB) breakpoint set – func – regex =. – shlib = libfoo. Dylib
Breaks the symbol (that is, the function name) that matches the specified regular expression
(lldb) breakpoint set –func-regex regular-expression
Sets a breakpoint on the file content by specifying a regular expression
(lldb) breakpoint set –source-pattern-regexp regular-expression –file