GenWikiLinux

From birchyHistory
Jump to: navigation, search
Line 4: Line 4:
 
== GREP ==
 
== GREP ==
 
grep [options] "foo" [file(s)]
 
grep [options] "foo" [file(s)]
 +
 +
You can omit the quotes if there are no spaces in the search term.
 +
If file is omitted, all files in current dir are searched.
 +
Multiple files can be specified separated by spaces or wildcarded (*.txt)
 +
'''While most tutorials assume that you are going to specify a file to search, using the search feature in vi makes more sense for working with a single file.'''
  
 
-i  ignore case
 
-i  ignore case
Line 9: Line 14:
 
-l  just show filenames
 
-l  just show filenames
 
-x  exact matches only
 
-x  exact matches only
 +
-w  match whole words only
 +
-m, --max-count=NUM      stop after NUM matches
 +
-a  text files only
 +
-r  recursive files inclusion
  
foo can be any Regular Expression
 
  
 +
foo can be any [[Regular Expression]]
  
egrep supports pipes ("or")
 
  
egrep "fruit|bread"
+
egrep supports pipes ("or") (= grep -E)
  
fgrep (fast grep, simple text, no RegEXp)
+
egrep "fruit|bread"
 +
 
 +
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"

Revision as of 13:37, 12 September 2015

Personal tools
Namespaces

Variants
Actions
Navigation
Tools