⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 grep.hlp

📁 grep帮助手册!对需要的人很有帮助!看了就知道!
💻 HLP
字号:
                                     -------------------------------------------------------------------------------                         Commands Reference, Volume 2-------------------------------------------------------------------------------grep CommandPurposeSearches a file for a pattern.Syntaxgrep [ -E | -F ] [ -i ] [ -h ] [ -s ] [ -v ] [ -w ] [ -x ] [ -y ] [ [ [ -b ] [-n ] ] | [ -c | -l |-q ] ] [ -p [ Separator ] ] { [ -e PatternList ... ] [ -fPatternFile ... ] | PatternList ... } [ File ... ]DescriptionThe grep command searches for the pattern specified by the Pattern parameter andwrites each matching line to standard output. The patterns are limited regularexpressions in the style of the ed or egrep command. The grep command uses acompact non-deterministic algorithm.The grep command displays the name of the file containing the matched line ifyou specify more than one name in the File parameter. Characters with specialmeaning to the shell ($, *, [, |, ^, (, ), \ ) must be in quotation marks whenthey appear in the Pattern parameter. When the Pattern parameter is not a simplestring, you usually must enclose the entire pattern in single quotation marks.In an expression such as [a-z], the - (minus sign) cml specifies a range,according to the current collating sequence. A collating sequence may defineequivalence classes for use in character ranges.    Notes:      1. Lines are limited to 2048 bytes.      2. Paragraphs (under the -p flag) are currently limited to a length of         5000 characters.      3. Do not run the grep command on a special file because it produces         unpredictable results.      4. Input lines should not contain the NULL character.      5. Input files should end with the new-line character.      6. The new-line character will not be matched by the regular expressions.      7. Although some flags can be specified simultaneously, some flags         override others. For example, the -l option takes precedence over all         other flags. And if you specify both the -E and -F flags, the last one         specified takes priority.Flags-b Precedes each line by the block number on which it was found. Use this flagto help find disk block numbers by context. The -b flag cannot be used withinput from stdin or pipes.-c Displays only a count of matching lines.-E Treats each pattern specified as an extended regular expression (ERE). A NULLvalue for the ERE matches every line.    Note: The grep command with the -E flag is the same as the egrep command,    except that error and usage messages are different and the -s flag functions    differently.-e PatternList Specifies one or more search patterns. This works like a simplepattern but is useful when the pattern begins with a - (minus). Patterns shouldbe separated by a new-line character. A NULL pattern can be specified by twoadjacent new-line characters or a quotation mark followed by a new-linecharacter ("\n). Each pattern is treated like a basic regular expression (BRE)unless the -E or -F flag is also specified.-F Treats each specified pattern as a string instead of a regular expression. ANULL string matches every line.    Note: The grep command with the -F flag is the same as the fgrep command,    except that error and usage messages are different and the -s flag functions    differently.-f PatternFile Specifies a file containing search patterns. Each pattern shouldbe separated by a new-line character, and an empty line is considered a NULLpattern. Each pattern is treated like a basic regular expression (BRE), unlessthe -E or -F flag is also specified.-h Suppresses file names when multiple files are specified.-i Ignores the case (uppercase or lowercase) of letters when making comparisons.-l Lists just the names of files (once) which contain matching lines. Each filename is separated by a new-line character. If standard input is searched, a pathname of (StandardInput) is returned. The -l flag with any combination of the -cand -n flags behaves like the -l flag only.-n Precedes each line with the relative line number in the file. Each filestarts at line 1, and the line counter is reset for each file processed.-p[Separator] Displays the entire paragraph containing matched lines. Paragraphsare delimited by paragraph separators, as specified by the Separator parameter,which are patterns in the same form as the search pattern. Lines containing theparagraph separators are used only as separators; they are never included in theoutput. The default paragraph separator is a blank line.-q Suppresses all writing to standard output, regardless of matching lines.Exits with a zero status if an input line is selected. The -q flag with anycombination of the -c, -l and -n flags behaves like the -q flag only.-s Suppresses error messages ordinarily written for nonexistent or unreadablefiles. Other error messages are not suppressed.-v Displays all lines not matching the specified pattern.-w Does a word search.-x Displays lines that match the specified pattern exactly with no additionalcharacters.-y Ignores the case of letters when making comparisons.PatternList Specifies one or more patterns to be used during the search. Thepatterns are treated as if they were specified using the -e flag.File Specifies a name of a file to be searched for patterns. If no File variableis given, the standard input is used.Exit StatusThis command returns the following exit values:0 A match was found.1 No match was found.>1 A syntax error was found or a file was inaccessible (even if matches werefound).Examples  1. To use a pattern that contains some of the pattern-matching characters *,     ^, ?, [, ], \(, \), \{, and \}, enter:     grep  "^[a-zA-Z]"  pgm.s     This displays every line in pgm.s whose first character is a letter.  2. To display all lines that do not match a pattern, enter:     grep  -v  "^#" pgm.s     This displays every line in pgm.s whose first character is not a # (pound     sign).  3. To display all lines in the file1 file that match either the abc or xyz     string, enter:     grep  -E  "abc|xyz"  file1  4. To search for a $ (dollar sign) in the file named test2, enter:     grep \\$ test2     The \\ (double backslash) characters are necessary in order to force the     shell to pass a \$ (single backslash, dollar sign) to the grep command. The     \ (single backslash) character tells the grep command to treat the     following character (in this example the $) as a literal character rather     than an expression character. Use the fgrep command to avoid the necessity     of using escape characters such as the backslash.Files/usr/bin/grep Contains the grep command.Related InformationThe ed command, egrep command, fgrep command, sed command.File Overview in AIX Version 4.3 System User's Guide: Operating System andDevices.Input and Output Redirection Overview in AIX Version 4.3 System User's Guide:Operating System and Devices.National Language Support Overview for Programming in AIX Version 4.3 GeneralProgramming Concepts: Writing and Debugging Programs.Shells Overview in AIX Version 4.3 System User's Guide: Operating System andDevices.-------------------------------------------------------------------------------                                     

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -