And another more complex example: find all IP addresses under /etc/ directory, only one match per file: $ grep -oERa -m1 "\b([0-9]{1,3}\.){3}[0-9]{1,3}\b" /etc/* /etc/alternatives/netcat:0.0.0.0 /etc/alternatives/rlogin:127.0.0.1 ……… /etc/systemd/resolved.conf:1.1.1....
Print the file name for each match. This is the default when there is more than one file to search. 打印每个匹配项的文件名。当需要搜索多个文件时,这是默认设置。 -h, --no-filename Suppress the prefixing of file names on output. This is the default when there is only one file (or on...
$ grep --help | grep -w "\-c" -c, --count print only a count of matching lines per FILE 1. 2. 带-i不区分大小写 $ grep --help | grep -w -i "\-c" -c, --count print only a count of matching lines per FILE -C, --context=NUM print NUM lines of output context 1. 2...
assume that the file is of typeTYPE. By default,TYPEisbinary, andgrepnormally outputs either a one-line message saying that a binary file matches, or no message if there is no match. IfTYPEiswithout-match,grepassumes that a binary file does not match; this is equivalent to the-Ioption....
-f filename, --file=filename Read a number of patterns from the file, one per line, and match them against each line of input. A data line is output if any of the patterns match it. The filename can be given as "-" to refer to the standard input. When -f is used, patterns ...
-H, --with-filename Print the file name for each match. This is the default when there is more than one file to search. -h, --no-filename Suppress the prefixing of file names on output. This is the default when there is only one file (or only standard input) to search. ...
If -o (--only-matching) is specified, print the offset of the matching part itself. -H, --with-filename Print the file name for each match. This is the default when there is more than one file to search. -h, --no-filename Suppress the prefixing of file names on output. ...
--exclude-dir=PATTERN directories that match PATTERN will be skipped. -L, --files-without-match print only names of FILEs containing no match -l, --files-with-matches print only names of FILEs containing matches -c, --count print only a count of matching lines per FILE ...
directories;ACTIONis'read','recurse',or'skip'-D,--devices=ACTION how to handle devices, FIFOs and sockets;ACTIONis'read'or'skip'-r,--recursive like --directories=recurse-R,--dereference-recursive likewise, but follow all symlinks--include=FILE_PATTERN search only files that match FILE_P ...
Write only the names of files containing selected lines to standard output. Pathnames are written once per file searched. If the standard input is searched, a pathname of (standard input) will be written, in the POSIX locale. In other locales, standard input may be replaced by something ...