2013-12-08 09:56:16 +01:00
|
|
|
# grep
|
|
|
|
|
2013-12-09 12:12:16 +01:00
|
|
|
> Matches patterns in input text
|
|
|
|
> Supports simple patterns and regular expressions
|
2013-12-08 09:56:16 +01:00
|
|
|
|
2013-12-09 12:12:16 +01:00
|
|
|
- search for an exact string
|
|
|
|
|
|
|
|
`grep {{something}} {{file_path}}`
|
2013-12-08 09:56:16 +01:00
|
|
|
|
2014-01-28 13:41:32 +01:00
|
|
|
- search recursively in current directory for an exact string
|
|
|
|
|
|
|
|
`grep -r {{something}} .`
|
|
|
|
|
2013-12-09 12:12:16 +01:00
|
|
|
- use a regex
|
2013-12-08 09:56:16 +01:00
|
|
|
|
2013-12-09 12:12:16 +01:00
|
|
|
`grep -e {{^regex$}} {{file_path}}`
|
2013-12-08 09:56:16 +01:00
|
|
|
|
2013-12-09 12:12:16 +01:00
|
|
|
- see 3 lines of context
|
2013-12-08 09:56:16 +01:00
|
|
|
|
2013-12-09 12:12:16 +01:00
|
|
|
`grep -C 3 {{something}} {{file_path}}`
|
2013-12-08 09:56:16 +01:00
|
|
|
|
A bunch of new pages:
common/: dig, gzip, rm, sort, zfs, zpool
linux/: apt-get, shutdown
osx/: airport, caffeinate, diskutil, networksetup open, pgrep, qlmanage, say, shutdown, sysctl, system_profiler
Edits to existing pages:
curl: Added simple download example
find: Added iname and size exmaples
grep: Edited -c description
ps: Added wide lines example
ssh: edited -D description, added simple port forwarding example
unzip: added list option
2014-02-10 21:36:05 +01:00
|
|
|
- print the count of matches instead of the matching text
|
2013-12-08 09:56:16 +01:00
|
|
|
|
2013-12-09 12:12:16 +01:00
|
|
|
`grep -c {{something}} {{file_path}}`
|
2013-12-08 09:56:16 +01:00
|
|
|
|
2013-12-09 12:12:16 +01:00
|
|
|
- use the standard input instead of a file
|
2013-12-08 09:56:16 +01:00
|
|
|
|
2013-12-09 12:12:16 +01:00
|
|
|
`cat {{file_path}} | grep {{something}}`
|