2013-12-08 19:56:16 +11:00
|
|
|
# grep
|
|
|
|
|
2013-12-09 22:12:16 +11:00
|
|
|
> Matches patterns in input text
|
|
|
|
> Supports simple patterns and regular expressions
|
2013-12-08 19:56:16 +11:00
|
|
|
|
2013-12-09 22:12:16 +11:00
|
|
|
- search for an exact string
|
|
|
|
|
|
|
|
`grep {{something}} {{file_path}}`
|
2013-12-08 19:56:16 +11:00
|
|
|
|
2013-12-09 22:12:16 +11:00
|
|
|
- use a regex
|
2013-12-08 19:56:16 +11:00
|
|
|
|
2013-12-09 22:12:16 +11:00
|
|
|
`grep -e {{^regex$}} {{file_path}}`
|
2013-12-08 19:56:16 +11:00
|
|
|
|
2013-12-09 22:12:16 +11:00
|
|
|
- see 3 lines of context
|
2013-12-08 19:56:16 +11:00
|
|
|
|
2013-12-09 22:12:16 +11:00
|
|
|
`grep -C 3 {{something}} {{file_path}}`
|
2013-12-08 19:56:16 +11:00
|
|
|
|
2013-12-09 22:12:16 +11:00
|
|
|
- print the number of matches
|
2013-12-08 19:56:16 +11:00
|
|
|
|
2013-12-09 22:12:16 +11:00
|
|
|
`grep -c {{something}} {{file_path}}`
|
2013-12-08 19:56:16 +11:00
|
|
|
|
2013-12-09 22:12:16 +11:00
|
|
|
- use the standard input instead of a file
|
2013-12-08 19:56:16 +11:00
|
|
|
|
2013-12-09 22:12:16 +11:00
|
|
|
`cat {{file_path}} | grep {{something}}`
|