Linux Survival
Search
Primary Menu
Skip to content
Home
Blog
Testimonials
Linux Links
Command List
Contact
Search for:
Linux Survival
The second piece to this puzzle is the "grep" command. This is one of the most obscure and easily-forgotten command names in Linux, but it is also one of the most useful. You can use "grep" to find patterns in data. For example, if you wanted to find every occurrence of the word "gold" in file "metals", you would type grep gold metals This would display every line of text in file "metals" that contained the pattern "gold". To use "grep" with a pipe, you simply leave out the file argument (just like we did with the "lpr -P zephyr" command on the previous page). For example, to list only those lines containing the word rabbit in Jester's joke files, you would type cat joke-1 joke-2 | grep rabbit See the example at right. Actually, an easier way to accomplish this would be to type grep rabbit joke* but that wouldn't have illustrated the use of "|". Click the right arrow.
Page 63
Where learning Linux is easy
Module 1 Introduction
Directory Structure
List Directory
View File Contents
Create Directory
Move and Rename File
Change Directory
Get Current Location
Quiz 1
End of Module 1
Module 2 Introduction
Pathnames
Copy File
Remove File
Remove Directory
File Security
Change File Permissions
Wildcards
Groups Memberships
Quiz 2
End of Module 2
Module 3 Introduction
Home Directories
Manual Pages
User Information
Find File
Concatenate Files
Redirect Output
Print
Print Job Status
Cancel Print Job
Quiz 3
End of Module 3
Module 4 Introduction
Copy Tree
Disk Space
Remove Tree
Process Status
Pipe Output
Pattern Matching
Kill Process
Quiz 4
Conclusion