Bash / Grep Question

Darkstar757

Diamond Member
Feb 1, 2003
3,190
6
81
Say you have a line that has the word "bug: in it.


I want to grep and retrieve only the line that contain the word "bug" twice in one line.


For example " The dog ate many bugs under the bud tree". I want the grep search to only locate these lines.


Thanks,
Darkstar
 

Crusty

Lifer
Sep 30, 2001
12,684
2
81
You need a regular expression to do what you want, unfortunately I'm rusty on mine so I can't give you one.
 

degibson

Golden Member
Mar 21, 2008
1,389
0
0
grep "bug.*bug" $FILE

It will find lines that contain two or more instances of 'bug'.