Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.

  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

Chapter 3. The Grep Family (Gnu & Sons)

Chapter 3. The Grep Family (Gnu & Sons)

The UNIX grep family consists of the commands grep, egrep, and fgrep. The grep command globally searches for regular expressions infiles and prints all lines that contain the expression. Theegrep and fgrep commands are simply variants of grep. The egrep command is an extended grep, supporting more RE metacharacters. The fgrep command, called fixed grep, and sometimes fast grep, treats all characters as literals; that is, regular expression metacharacters aren't special—they match themselves.

Linux uses the Gnu version of grep, which in functionality is much the same as grep, but better. In addition to POSIX character classes (see Tables 3.1 and 3.2), there are a number of new options, including -G, -E, and -F, which allow you to use regular grep for everything, and still get the functionality of both egrep and fgrep.[1]

[1] To use grep recursively, see Appendix A for Gnu rgrep and xargs.


  

You are currently reading a PREVIEW of this book.

                                                                                                                    

Get instant access to over $1 million worth of books and videos.

  

Start a Free Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint