If grep decides the file is a text file, it strips the CR characters from the original file contents (to make regular expressions with ^ and $ work correctly). Specifying -U overrules this guesswork, causing all files to be read and passed to the matching mechanism verbatim; if the file ...
If this option is used multiple times or is combined with the -f (--file) option, search for all patterns given. This option can be used to protect a pattern beginning with “-”. -f FILE, --file=FILE Obtain patterns from FILE, one per line. If this option is used multiple ...
user@linux:~$catfile.txt|grepword word words sword 如果你希望grep僅列印完全匹配的短語(即,它們周圍有空格並且不是其他單詞的子字串),你可以使用-w/--word-regexp標誌來啟用整體詞匹配。 如果短語顯示為單行,你可以使用相同的想法來匹配短語,使用-x/--line-regexp。
-e PATTERN, --regexp=PATTERN Use PATTERN as the pattern. This can be used to specify multiple search patterns, or to protect a pattern beginning with a hyphen (-). 即,在 -e 选项后面的 PATTERN 参数会被当成要匹配的模式字符串,提供多个 -e 选项就能匹配多个模式字符串。 注意不要在单个 -e ...
Use PATTERN as the pattern. If this option is used multiple times or is combined with the -f (--file) option, search for all patterns given. This option can be used to protect a pattern beginning with “-”. 使用模式作为模式。如果此选项多次使用或与-f (- file)选项组合使用,则搜索给定...
grep - print lines matching a patterngrep [OPTIONS] PATTERN [FILE...] grep [OPTIONS] [-e PATTERN | -f FILE] [FILE...]
the valueofServerRoot is prepended--so'log/access_log':#withServerRootsetto'/www'will be interpreted by the:# ServerRoot:The topofthe directory tree under which the server's:# ServerRoot at a non-local disk,be sure to specify a local disk on the:# same ServerRootformultiple httpd daemons...
-e PATTERN, --regexp=PATTERN Use PATTERN as the pattern. This can be used to specifymultiple search patterns, or toprotecta patternbeginning with a hyphen(-). (-e is specified by POSIX.) -f FILE, --file=FILE Obtain patterns from FILE, one per line. The empty file contains zero patte...
To exclude particular words or lines, use the -invert-match option. Use grep -v as a shorter alternative. Exclude multiple words with grep by adding -E and use a pipe (|) to define the specific words. Optionally make it case insensitive with the -i as listed above. ...
Example: grep -i 'hello world' menu.h main.c PATTERNS can contain multiple patterns separated by newlines. Pattern selection and interpretation: -E, --extended-regexp PATTERNS are extended regular expressions -F, --fixed-strings PATTERNS are strings -G, --basic-regexp PATTERNS are basic ...