Red Hat ENTERPRISE LINUX 3 - STEP BY STEP GUIDE Manual page 52

Table of Contents

Advertisement

38
3.10.3. The
grep
The
command is useful for finding specific character strings in a file. For example, if you want
grep
to find every reference made to "coffee" in the file
grep coffee sneakers.txt
Each line in that file where the word "coffee" is found is displayed.
Tip
Unless otherwise specified,
is different than searching for coffee. Among
search through a file. Read the
3.10.4. I/O Redirection and Pipes
You can use pipes and output redirection when you want to store and/or print information to read at a
later time.
You can, for example, use
saved as a file or sent to a printer.
To print information about references to "coffee" in
grep coffee sneakers.txt | lpr
3.10.5. Wildcards and Regular Expressions
What if you forget the name of the file you are looking for? Using wildcards or regular expressions,
you can perform actions on a file or files without knowing the complete file name. First type out what
you know, and then substitute the remainder with a wildcard. Wildcards are special symbols that can
be substituted for letters, numbers, and symbols. Wildcards make finding particular directories and
files easier than examining long directory listings to find what you are searching for.
Tip
To read more about wildcards and regular expressions, take a look at the
Remember that you can save the file to a text file by typing
you can open and read the file with
print the file, be aware that it is quite long.
To find a file is called "sneaksomething.txt," type:
ls sneak*.txt
The name of the file appears:
sneakers.txt
Command
searches are case sensitive. That means that searching for Coffee
grep
man page for more about this command.
grep
to search for particular contents of a file, then have those results either
grep
less
sneakers.txt
's options is
grep
-i
sneakers.txt
man bash | col -b
or with an editor such as
Chapter 3. Shell Prompt Basics
, you would type:
, which allows for a case-insensitive
, for example, type:
man page (
bash
bash.txt

(
). If you want to
vi
vi bash.txt
).
man bash
. Then,

Advertisement

Table of Contents
loading

This manual is also suitable for:

Enterprise linux 3

Table of Contents