-
Notifications
You must be signed in to change notification settings - Fork 0
/
Commands-Search
69 lines (26 loc) · 1.48 KB
/
Commands-Search
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[SEARCH]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]
grep pattern files
[search pattern in files]
-------------------------------------------------------------------------------------
grep -r pattern dir
[search recursively for pattern in dir]
-------------------------------------------------------------------------------------
grep -rnw '/path/to/somewhere/' -e 'pattern'
[search recursively for pattern in specific dir (ie. './' which means current dir ):
-r or -R is recursive,
-n is line number, and
-w stands for match the whole word
-l (lower-case L) can be added to just give the file name of matching files)]
-------------------------------------------------------------------------------------
locate file
[find all instances of file]
-------------------------------------------------------------------------------------
find /home/bob -name "index*"
[find all filenames that start with "index" in a folder /home/bob]
-------------------------------------------------------------------------------------
find /home -size +10000k
[find files larger than 10000k (~10MB) in folder /home]
-------------------------------------------------------------------------------------
find /etc -name '*.conf' -exec cp {} /mnt/files \;
[find all files that are ending with .conf extension in a folder /etc and then copy all of those files to folder /mnt/files]
-------------------------------------------------------------------------------------