Skip to Main Content
UNIX® Shells by Example, Third Edition
book

UNIX® Shells by Example, Third Edition

by Ellie Quigley
October 2001
Intermediate to advanced content levelIntermediate to advanced
1040 pages
22h 50m
English
Pearson
Content preview from UNIX® Shells by Example, Third Edition

3.1. The grep Command

3.1.1. The Meaning of grep

The name grep can be traced back to the ex editor. If you invoked that editor and wanted to search for a string, you would type at the ex prompt:

: /pattern/p

The first line containing the string pattern would be printed as “p” by the print command. If you wanted all the lines that contained pattern to be printed, you would type:

: g/pattern/p

When g precedes pattern, it means “all lines in the file,” or “perform a global substitution.”

Because the search pattern is called a regular expression, we can substitute RE for pattern and the command reads:

: g/RE/p

And there you have it: the meaning of grep and the origin of its name. It means “globally search for the regular expression (RE) and ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

UNIX® Shells by Example Fourth Edition

UNIX® Shells by Example Fourth Edition

Ellie Quigley
Storage Area Networks For Dummies®

Storage Area Networks For Dummies®

Christopher Poelker, Alex Nikitin

Publisher Resources

ISBN: 013066538XPurchase book