You are previewing grep Pocket Reference.

grep Pocket Reference

Cover of grep Pocket Reference by John Bambenek... Published by O'Reilly Media, Inc.
O'Reilly logo

Chapter 1. grep Pocket Reference

Introduction

Chances are that if you’ve worked for any length of time on a Linux system, either as a system administrator or as a developer, you’ve used the grep command. The tool is installed by default on almost every installation of Linux, BSD, and Unix, regardless of distribution, and is even available for Windows (with wingrep or via Cygwin).

GNU and the Free Software Foundation distribute grep as part of their suite of open source tools. Other versions of grep are distributed for other operating systems, but this book focuses primarily on the GNU version, as it is the most prevalent at this point.

The grep command lets the user find text in a given file or output quickly and easily. By giving grep a string to search for, it will print out only lines that contain that string and can print the corresponding line numbers for that text. The “simple” use of the command is well-known, but there are a variety of more advanced uses that make grep a powerful search tool.

The purpose of this book is to pack all the information an administrator or developer could ever want into a small guide that can be carried around. Although the “simple” uses of grep do not require much education, the advanced applications and the use of regular expressions can become quite complicated. The name of the tool is actually an acronym for “Global Regular-Expression Print,” which gives an indication of its purpose.

GNU grep is actually a combination of four different tools, each ...

The best content for your career. Discover unlimited learning on demand for around $1/day.