22/12/15

Grep Quick Reference

Basic grep usage



Get lines which does not begin with "#" or ";"?
grep "^[^#;]" /path/to/my/file 
Search recursively through single file extension
grep -r --include=<pattern> <string> <directory>
Print two line after and before the match.
grep -A 2 -B 2 "pattern" /path/to/my/file"
Print the file name for each match
grep -H word /path/to/file

Nessun commento :

Posta un commento