(Office) Notepad text search command _grep

        Reference grain Academy linux video tutorial: http: //www.gulixueyuan.com/course/300/task/7091/show

      

grep Text Search command: [text search is a powerful tool that can use regular expressions to search text, and print out the matching rows. ]
 1 difference .find and grep are: 
  the Find command in the system search for qualified filename, if need fuzzy search, you need to wildcard queries, the search time is the filename exact match. 
  Grep command is used to file searching for qualifying field names, if needed fuzzy query, use a regular expression matching, when the search string is the match. 
  
2 syntax:. 
  grep [ -abcEFGhHilLnqrsvVwxy] [- a <to display the number of columns>] [ -B <shows the number of columns>] [- C <number display column>] [- d <operates>] [- e <style templates>] [- f <template file>] [- Help] [template style] [file or directory ...]
 3 parameters:.
     -a or - text: do not ignore the binary data.
    -A <the number of lines> or --after-context = <number of lines displayed> : In addition to displaying the template in line with the row outside the pattern, and then display the contents of the row.
    -b or - byte - offset: Prior to demonstrate compliance with the line style, mark the first character of the line number.
    -B <the number of lines> or --before-context = <number of lines displayed> :
    In addition to displaying the line styles in line outside, and displays the contents of the previous line. -c or -count: the number of columns is calculated in line with the style.
    -C <the number of lines> or --context = <number of lines displayed> or - <the number of lines> : In addition to displaying the line style than meet, and the display contents before the row.
    -d <action> or --directories = <action> : When you specify when you want to find is a directory rather than a file, you must use this parameter, otherwise the grep command will return information and stop action.
    -e <style templates> or --regexp = <template pattern> : find files specified string as the contents of the style.
    -E or --extended- regexp: the style extends the regular expression used.
    -f <rule file> or --file = <rule file> : specify rules file, the contents of which contain one or more regular pattern, so grep to find content file rule conditions are met, the format for each line of a regular pattern.
    -F or - Fixed - regexp: a list of the style as a fixed string.
    -G or --basic- regexp: the style of notation as ordinary use.
    -h or --no- filename: Prior to demonstrate compliance with the line style, does not indicate the file name of the row belongs.
    -H or --with- filename:
    Prior to demonstrate compliance with the line style, it represents a file name of the row belongs. -i or --ignore-Case : Ignore character case differences.
    -l-with- or --file The matches: lists the file name of the file contents match the specified style.
    -L-without- or --files match: lists the contents of the file file name does not comply with the specified style.
    -n or --line- Number The: Prior to demonstrate compliance with the line style, mark the number of columns in the row number.
    -o or --only- matching: PATTERN only matching portion.
    -q or --quiet or - Silent: do not display any information.
    -r or --recursive: effect of this parameter is specified and " -d recurse " the same parameters.
    -s or --no- messages: do not display an error message.
    -v or --revert- match: Displays all lines matching text.
    -V or - Version: display version information.
    -w or --word- regexp: show only whole word matching columns.
    --line- -x regexp: show only matching column full column.
    -y: effect of this parameter is specified and " -i " the same parameters. 
4 Case:
      1 . Find the current directory prefix is the BUILDING file, and characters including command 
     grep command BUILDING *
      2 Find the file suffix BUILDING.txt in the current directory, and the characters are included in command command.. 
     Grep command * BUILDING. TXT
      3 . recursively find qualified files. For example, to find the specified directory // and its subdirectories (subdirectories if one exists) all the files that contain the string "update" file, and print out the contents of the line where the string, command is: 
     grep -r the Command / usr / local / Tomcat
      4 . reverse lookup. Each of the previous example is to find and print out the qualifying rows by " -v " argument can print out the contents do not meet the conditions of the line. 
     grep -v the Command / usr / local / Tomcat

 

Guess you like

Origin www.cnblogs.com/historylyt/p/12161634.html