Search

Thursday, June 18, 2009

The general command-line syntax for GREP is

grep [options] searchstring [file(s) ... ]
options consist of one or more letters, preceded by a
hyphen (-), that let you change various aspects of
GREP's behavior.
searchstring gives the pattern to search for.
file(s) tells GREP which files to search. (If you don't
specify a file, GREP searches its standard input; this
lets you use GREP with pipes and redirection.) If you
find that the results of your GREP are longer than one
screen, you can redirect the output to a file. For
example, you could use this command
GREP "Bob" *.txt >gfile
which searches all files in the current directory that
end with .TXT, then places the results in a file called
GFILE. (You can name this file anything you like.)
Then, use your word processor (or Turbo C++'s editor)
to access GFILE to read the results of the search.
The command
GREP ?
prints a brief help screen showing GREP's command-line
options, special characters, and defaults. (See the
description of the -u command-line option for
information on how to change GREP's defaults.)

GREP options =======================================================
In the command line, options are one or more single
characters preceded by a hyphen (-). Each individual
character is a switch that you can turn on or off: A
plus symbol (+) after a character turns the option on;
a hyphen (-) after the character turns the option off.
The + sign is optional; for example, -r means the same
thing as -r+. You can list multiple options




- 13 -






individually (like this: -i -d -l), or you can combine
them (like this: -ild or -il, -d, and so on); it's all
the same to GREP.
Here are the GREP option characters and their meanings:

No comments:

Post a Comment