This is the default when there is only one file (or only standard input) to search. h, -no-filename Suppress the prefixing of file names on output. This is the default when there is more than one file to search. H, -with-filename Print the file name for each match. If -o (-only-matching) is specified, print the offset of the matching part itself. Output Line Prefix Control -b, -byte-offset Print the 0-based byte offset within the input file before each line of output. s, -no-messages Suppress error messages about nonexistent or unreadable files. Exit immediately with zero status if any match is found, even if an error was detected. q, -quiet, -silent Quiet do not write anything to standard output. o, -only-matching Print only the matched (non-empty) parts of a matching line, with each such part on a separate output line. When the -v or -invert-match option is also used, grep stops after outputting NUM non-matching lines. When the -c or -count option is also used, grep does not output a count greater than NUM. When grep stops after NUM matching lines, it outputs any trailing context lines. This enables a calling process to resume a search. If the input is standard input from a regular file, and NUM matching lines are output, grep ensures that the standard input is positioned to just after the last matching line before exiting, regardless of the presence of trailing context lines. m NUM, -max-count=NUM Stop reading a file after NUM matching lines. The scanning will stop on the first match. l, -files-with-matches Suppress normal output instead print the name of each input file from which output would normally have been printed. L, -files-without-match Suppress normal output instead print the name of each input file from which no output would normally have been printed. The deprecated environment variable GREP_COLOR is still supported, but its setting does not have priority. The colors are defined by the environment variable GREP_COLORS. color, -colour Surround the matched (non-empty) strings, matching lines, context lines, file names, line numbers, byte offsets, and separators (for fields and groups of context lines) with escape sequences to display them in color on the terminal. With the -v, -invert-match option (see below), count non-matching lines. General Output Control -c, -count Suppress normal output instead print a count of matching lines for each input file. For a regular expression pattern, this is like parenthesizing the pattern and then surrounding it with ^ and $. x, -line-regexp Select only those matches that exactly match the whole line. Word-constituent characters are letters, digits, and the underscore. Similarly, it must be either at the end of the line or followed by a non-word constituent character. The test is that the matching substring must either be at the beginning of the line, or preceded by a non- word constituent character. w, -word-regexp Select only those lines containing matches that form whole words. v, -invert-match Invert the sense of matching, to select non-matching lines. i, -ignore-case Ignore case distinctions in both the PATTERN and the input files. The empty file contains zero patterns, and therefore matches nothing. If this option is used multiple times or is combined with the -e (-regexp) option, search for all patterns given. f FILE, -file=FILE Obtain patterns from FILE, one per line. This option can be used to protect a pattern beginning with “-”. If this option is used multiple times or is combined with the -f (-file) option, search for all patterns given. Matching Control -e PATTERN, -regexp=PATTERN Use PATTERN as the pattern. This is highly experimental and grep -P may warn of unimplemented features. P, -perl-regexp Interpret the pattern as a Perl-compatible regular expression (PCRE). G, -basic-regexp Interpret PATTERN as a basic regular expression (BRE, see below). F, -fixed-strings Interpret PATTERN as a list of fixed strings (instead of regular expressions), separated by newlines, any of which is to be matched. Matcher Selection -E, -extended-regexp Interpret PATTERN as an extended regular expression (ERE, see below). V, -version Output the version number of grep and exit. Option -help Output a usage message and exit. Grep $ grep a test1 Cat Man $ grep an test1 ManĢ. จากตัวอย่าง file test1 $ cat test1 Ant Bee Cat Dog Fly
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |