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 ...
Get Practical Linux now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.