# using grep to filter file
``` bash
# file with regex
# you need a parameter -E to enable regex match
grep -E '4000+' -r .
# filter under current folder
grep 'key' filename-*.xml
grep 's.format(' -r . --include '*Test.java'
# filter with recursive
grep 'key' --include 'filename-*.java' -r .
# filter under special folder, -r is required
grep 'sleep' -r ./**/usermanagement
# print line around search result, -5 = -C5, 5 lines forward = -5A, 5 lines backward = -5B
cat xxx | grep -C5 'key'
# find lines with timestamp
grep '10:10:01' server.log
# find line with timestamp and company id
grep '10:10:01.*datPLT10' server.log
also you can use multiple group
grep 'key1' server.log | grep 'key2'
# find wil OR operation
grep 'key1\|key2' file.log
PS: -r == -R
```
## find vs grep
grep is mainly focuse on search **content** in file
find is mainly focuse on search **file** in system