1
0
Fork 0
mirror of https://github.com/tldr-pages/tldr.git synced 2024-11-02 09:17:57 +01:00
tldr/pages/common/grep.md

37 lines
698 B
Markdown
Raw Normal View History

2013-12-08 09:56:16 +01:00
# grep
> Matches patterns in input text
> Supports simple patterns and regular expressions
2013-12-08 09:56:16 +01:00
- search for an exact string
2015-10-22 09:31:52 +02:00
`grep {{something}} {{file_path}}`
2013-12-08 09:56:16 +01:00
- search recursively in current directory for an exact string
`grep -r {{something}} .`
- use a regex
2013-12-08 09:56:16 +01:00
`grep -e {{^regex$}} {{file_path}}`
2013-12-08 09:56:16 +01:00
- see 3 lines of context
2013-12-08 09:56:16 +01:00
`grep -C 3 {{something}} {{file_path}}`
2013-12-08 09:56:16 +01:00
2015-10-22 09:31:52 +02:00
- print the count of matches instead of the matching text
2013-12-08 09:56:16 +01:00
`grep -c {{something}} {{file_path}}`
2013-12-08 09:56:16 +01:00
2016-01-05 06:30:21 +01:00
- print line number for each match
`grep -n {{something}} {{file_path}}`
- use the standard input instead of a file
2013-12-08 09:56:16 +01:00
`cat {{file_path}} | grep {{something}}`
2014-07-27 10:23:56 +02:00
- invert match for excluding specific strings
2014-07-27 14:10:52 +02:00
`grep -v {{something}}`