O'Reilly logo

Practical Linux by Bill Ball, John Ray, Michael Turner, M. Drew Streib

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Searching Text Files

Linux also comes with a number of programs that you can use to search files. Some of these commands use regular expressions (introduced in Chapter 2, "Entering Commands"), while others, such as the strings command, offer limited search capabilities.

Using the grep Command

The grep command is part of a family of commands: grep, fgrep, and egrep. These commands are closely related, but have different capabilities in the type of expressions or wildcards that can be used on the command line. For example, to look for any occurrence of the word hacker in the file cathedral-bazaar.txt:

 $ grep -n hacker cathedral-bazaar.txt 278: happy extreme, is that a lot of users are hackers too. Because source 279: code is available, they can ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required