Places a line containing a group separator (--) between contiguous groups of matches. With the -o or --only-matching option, this has no effect and a warning is given. File and Directory Selection -a, --text Process a binary file as if it were text; this is equivalent to the --...
--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 -T, --initial-...
-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 -T, --initial-tab make tabs line up (if needed) -Z, --null print 0 byte after...
grep[OPTION]...PATTERN[FILE]...Usage:grep[OPTION]...PATTERN[FILE]...SearchforPATTERNineachFILEor standard input.PATTERNis,bydefault,a basic regularexpression(BRE).Example:grep-i'hello world'menu.h main.c Regexp selection and interpretation:-E,--extended-regexpPATTERNis an extended regularexpr...
$ grep pattern filenamethisisthe line containing pattern 文件可以指定多个。 $ grep"match_text"file1 file2 file3 ... 匹配模式也可以指定多个,每个格式之间是or的关系 $ grep -e"match_text1"f -e"match_text2"file grep命令支持使用正则表达式。以上的命令使用的都是基础的正则表达式,-E选项使grep可以...
not containing) it or to have it replaced with something else. This chapter discusses two important filters that are specially suited for these tasks – grep and sed. grep takes care of all search requirements we may have. sed goes further and can even manipulate the ...
You can also use the -w switch, which will tell grep that the string must match the whole line. Obviously, this will only work in situations where you’re not expecting the rest of the line to have any text at all. Exclude pattern ...
So, first, let’s remove the lines containing the comments. The following output is produced: # grep -v '^#' /etc/sudoersDefaults!visiblepw Defaults env_reset Defaults env_keep="COLORS DISPLAY HOSTNAME HISTSIZE KDEDIR LS_COLORS"Defaults env_keep+="MAIL PS1 PS2 QTDIR USERNAME LANG LC_ADDRE...
not newlineMiscellaneous: // 各种各样的-s, --no-messages suppress error messages-v, --invert-match select non-matching lines // 搜索不匹配的行-V, --version display version information and exit--help display this help text and exitOutput control: // 输出控制-m, --max-count=NUM stop af...
This command displays the line containing the string plus 4 lines of text after theensstring in theifconfigcommand.Output Conversely, in the example below, the use of the -B flag will display the line containing the search string plus 3 lines of text before theetherstring in theifconfigcomma...