-c Match Count only: Prints only a count of matching lines. For each file
that contains at least one matching line, GREP prints the file name and
a count of the number of matching lines. Matching lines are not
printed. This option is off by default.
-d Search subdirectories: For each file specified on the command line,
GREP searches for all files that match the file specification, both in
the directory specified and in all subdirectories below the specified
directory. If you give a file without a path, GREP assumes the files
are in the current directory. This option is off by default.
-i Ignore case: GREP ignores upper/lowercase differences (case folding).
When this option is on, GREP treats all letters a to z as identical to
the corresponding letters A to Z in all situations. This option is on
by default.
-l List file names only: Prints only the name of each file containing a
match. After GREP finds a match, it prints the file name and processing
immediately moves on to the next file. This option is off by default.
-n Line Numbers: Each matching line that GREP prints is preceded by its
line number. This option is off by default.
-o UNIX output format: Changes the output format of matching lines to
support more easily the UNIX style of command-line piping. All lines of
output are preceded by the name of the file that contained the matching
line. This option is off by default.
-r Regular expression search: The text defined by searchstring is treated
as a regular expression instead of as a literal string. This option is
on by default. This option is on by default.
A regular expression is one or more occurrences of one or more
characters optionally enclosed in quotes. The following symbols are
treated specially:
^ start of line $ end of line
- 14 -
. any character \ quote next character
* match zero or more + match one or more
[aeiou0-9] match a, e, i, o, u, and 0 thru 9
[^aeiou0-9] match anything but a, e, i, o, u, and 0 thru 9
-u Update options: GREP will combine the options given on the command line
with its default options and write these to the GREP.COM file as the
new defaults. (In other words, GREP is self-configuring.) This option
allows you to tailor the default option settings to your own taste. If
you want to see what the defaults are in a particular copy of GREP.COM,
type
GREP ?
at the DOS prompt. Each option on the help screen will be followed by a
+ or a - depending on its default setting. This option is off by
default.
-v Nonmatch: Prints only nonmatching lines. Only lines that do not contain
the search string are considered to be nonmatching lines. This option
is off by default.
-w Word search: Text found that matches the regular expression is
considered a match only if the character immediately preceding and
following cannot be part of a word. The default word character set
includes A to Z, 0 to 9, and the underscore ( _ ). This option is off
by default.
An alternate form of this option lets you specify the set of legal word
characters. Its form is -w[set], where set is any valid regular
expression set definition.
If you define the set with alphabetic characters, it is automatically
defined to contain both the uppercase and lowercase values for each
letter in the set (regardless of how it is typed), even if the search
is case-sensitive. If you use the -w option in combination with the -u
option, the new set of legal characters is saved as the default set.
-z Verbose: GREP prints the file name of every file searched. Each
matching line is preceded by its line number. A count of matching lines
in each file is given, even if the count is zero. This option is off by
default.
No comments:
Post a Comment