-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathfind.rts
More file actions
67 lines (35 loc) · 1.46 KB
/
find.rts
File metadata and controls
67 lines (35 loc) · 1.46 KB
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
56
57
58
59
60
61
62
63
64
65
66
How do I perform a case insensitive search?
Replace -name option with -iname as follows:
::
find / -type d -iname "apt" -ls
OR
::
find / -type d -iname "apt"
The patterns ‘apt’ match the directory names ‘apt’, ‘APT’, ‘Apt’, ‘apT’, etc.
How do I find a directory called project.images?
Type any one of the following command:
::
find / -type d -iname "project.images" -ls
OR
::
find / -type d -name "project.images" -ls
OR
::
find / -type d -name "project.images"
A note about locate command
To search for a file/dir named exactly project.images (not *project.images*), type:
locate -b '\project.images'
find and delete all file in ./ that haven’t been modified since 90 day:
::
find ./ -mtime 90 -exec rm -Rf {} \;
I'd strongly suggest not to use find -L for the task (see below for explanation). Here are some other ways to do this:
If you want to use a "pure find" method, it should rather look like this:
::
find . -xtype l
(xtype is a test performed on a dereferenced link) This may not be available in all versions of find, though. But there are other options as well;
You can also exec test -e from within the find command:
::
find . -type l -! -exec test -e {} \; -print
Even some grep trick could be better (i.e. safer) than find -L, but not exactly such as presented in the question (which greps in entire output lines, including filenames):
::
find . -type l -exec sh -c "file -b {} | grep -q ^broken" \; -print