By default, under MS-DOS and Microsoft Windows, grep guesses the file type by looking at the contents of the first 32 KB read from the file. Shell scripts intended to be portable to traditional grep should avoid both -q and -s and should redirect output to /dev/null instead. Portability note: unlike GNU grep, traditional grep did not conform to POSIX.2, because traditional grep lacked a -q option and its -s option behaved like GNU grep's -q option. Suppress error messages about nonexistent or unreadable files. Recurse in directories skip file matching PATTERN. Recurse in directories only searching file matching PATTERN. Read all files under each directory, recursively this is equivalent to the -d recurse option. Exit immediately with zero status if any match is found, even if an error was detected. This can incur a performance penalty.īe quiet do not write anything to standard output. This is especially useful for tools like zgrep, e.g., gzip -cd foo.gz |grep -H -label=foo something Show only the part of a matching line that matches PATTERN.ĭisplays input actually coming from standard input as input coming from file LABEL. Prefix each line of output with the line number within its input file. However, -mmap can cause undefined behavior (including core dumps) if an input file shrinks while grep is operating, or if an I/O error occurs. In some situations, -mmap yields better performance. If possible, use the mmap system call to read input, instead of the default read system call. 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 after the last matching line before exiting, regardless of the presence of trailing context lines. Stop reading a file after NUM matching lines. Suppress normal output instead print the name of each input file from which output would normally print. Suppress normal output instead print the name of each input file from which no output would normally print. Ignore case distinctions in both the PATTERN and the input files. Process a binary file as if it did not contain matching data this is equivalent to the -binary-files=without-match option. Suppress the prefixing of file names on output when multiple files are searched. Interpret PATTERN as a basic regular expression (see below). The empty file contains zero patterns, and therefore matches nothing. Interpret PATTERN as a Perl regular expression. Interpret PATTERN as a list of fixed strings, separated by newlines, that may be matched. Use PATTERN as the pattern useful to protect patterns beginning with " -". If ACTION is recurse, grep reads all files under each directory, recursively this is equivalent to the -r option. If ACTION is skip, directories are silently skipped. By default, ACTION is read, which means that directories are read as if they were ordinary files. If an input file is a directory, use ACTION to process it. If ACTION is skip, devices are silently skipped. By default, ACTION is read, which means that devices are read as if they were ordinary files. If an input file is a device, FIFO or socket, use ACTION to process it. With the -v, -invert-match option (see below), count non-matching lines. Suppress normal output instead print a count of matching lines for each input file. WHEN may be ' never', ' always', or ' auto' Surround the matching string with the marker find in GREP_COLOR environment variable. Warning: grep -binary-files=text might output binary garbage, which can have nasty side effects if the output is a terminal and if the terminal driver interprets some of it as commands. If TYPE is text, grep processes a binary file as if it were text this is equivalent to the -a option. If TYPE is without-match, grep assumes that a binary file does not match this is equivalent to the -I option. By default, TYPE is binary, and grep normally outputs either a one-line message saying that a binary file matches, or no message if there is no match. If the first few bytes of a file indicate that the file contains binary data, assume that the file is of type TYPE. Print the byte offset in the input file before each line of output. Places a line containing - between contiguous groups of matches. Print NUM lines of leading context before matching lines. Process a binary file as if it were text this is equivalent to the -binary-files=text option. Print NUM lines of trailing context after matching lines.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |