Changes

Jump to navigation Jump to search
530 bytes added ,  06:35, 18 August 2016
no edit summary
Line 37: Line 37:  
grep -r "password" *
 
grep -r "password" *
 
ifconfig eth0 | grep -oiE '([0-9A-F]{2}:){5}[0-9A-F]{2}' # Show eth0 MAC address
 
ifconfig eth0 | grep -oiE '([0-9A-F]{2}:){5}[0-9A-F]{2}' # Show eth0 MAC address
grep -Eio '[a-z0-9._-]+@[a-z0-9.-]+[a-z]{2,4}' file.txt  # Extract e-main addresses from file.txt
+
grep -Eio '[a-z0-9._-]+@[a-z0-9.-]+[a-z]{2,4}' file.txt  # Extract e-main addresses from file.txt</source>
    +
== Find files containing text pattern ==
 +
grep -rnw '/path/' -e "pattern"
   −
</source>
+
* r or -R is recursive,
 +
* n is line number, and
 +
* w stands match the whole word.
 +
* l (lower-case L) can be added to just give the file name of matching files.
 +
--exclude or --include parameter could be used for efficient searching. Something like below:
 +
grep --include=\*.{c,h} -rnw '/path/to/somewhere/' -e "pattern"
 +
grep --exclude=*.o -rnw '/path/to/somewhere/' -e "pattern"
 +
grep --exclude-dir={dir1,dir2,*.dst} -rnw '/path/to/somewhere/' -e "pattern"

Navigation menu