-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgrep.bash
36 lines (30 loc) · 1012 Bytes
/
grep.bash
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# grep Notes
# search for word within files in currect directory
grep hello *
# recursively search all files for a string
# source: https://stackoverflow.com/a/15622352/
# source: https://stackoverflow.com/a/16957078/
cd /path/you/want
grep -r "word" .
grep -ir "WoRd" . # ignores case
grep -R "word" dir/ # alt flag of -R
# -r recursive
# -n line number
# -w whole word
grep -rnw '/path/to/somewhere/' -e 'pattern'
# grep is suppress file name if given one file
grep grep grep.bash
grep grep grep.bash /dev/null # if you want the file name
# show lines not showing pattern
grep -v bash grep.bash
# search all files in directory
# source: https://stackoverflow.com/a/16957078/6873133
grep -rnw . -e 'word'
# -r = recursive
# -n = line number
# -w = match whole word
# search through files, add -n for line numbers
# source: https://superuser.com/a/614589
grep "some string" . -R
# H for file printing, i for case-insensitive, R for recursive search, E for regex
grep -HiRE "some string|other string" .