Schlagwort-Archive: grep

Linux: Dateien in Unterverzeichnissen nach Text durchsuchen

Search sub directories recursively using grep

Pass the -r option to grep command to search recursively through an entire directory tree. With this option one can search the current directory and and all levels of subdirectories by passing the -r or -R to the grep command. The syntax is:

grep -r 'word-to-search' *

 

 

grep -r 'main()' *

The following example would search for /etc/ and all of its subdirectories for every line containing the ip address ‘192.168.1.254’:

grep -r '192.168.1.254' /etc/

EMail Adressen aus einer Textdatei filtern

Möchte man z.b. aus einem Log-File nur die Email-Adressen extrahieren, kann man das mit grep machen:

$ grep -i -o ‚[A-Z0-9._%+-]+@[A-Z0-9.-]+.[A-Z]{2,4}‘ file.csv

Quelle:
http://stackoverflow.com/questions/19940935/extract-email-addresses-from-text-file-using-regex-with-bash-or-command-line