GenWikiLinux
From birchyHistory
Line 3: | Line 3: | ||
== GREP == | == GREP == | ||
− | grep [OPTIONS] " | + | grep [OPTIONS] "REGEXP" [FILES(s)] |
+ | *"REGEXP" can be any [[Regular Expression]] | ||
*Single or double quotes can be used. | *Single or double quotes can be used. | ||
− | *Quotes can be omitted if there are no spaces in the search term. | + | *Quotes can be omitted if there are no spaces in the search term. |
+ | |||
*If file is omitted, all files in current dir are searched. | *If file is omitted, all files in current dir are searched. | ||
*Multiple files can be specified separated by spaces or wildcarded (*.txt) | *Multiple files can be specified separated by spaces or wildcarded (*.txt) | ||
Line 21: | Line 23: | ||
-r recursive files inclusion | -r recursive files inclusion | ||
− | + | '''egrep''' supports pipes ("or") (= grep -E) | |
− | + | ||
− | + | ||
− | egrep supports pipes ("or") (= grep -E) | + | |
egrep "fruit|bread" | egrep "fruit|bread" | ||
− | fgrep (fast grep, simple text, no RegEXp) ( | + | '''fgrep''' (fast grep, simple text, no RegEXp) (= grep -F) |
Can pipe the output of another command | Can pipe the output of another command | ||
ls |grep blah lists all files in the current directory whose names contain the string "blah" | ls |grep blah lists all files in the current directory whose names contain the string "blah" |