-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathfunc_find.sh
49 lines (46 loc) · 1.06 KB
/
func_find.sh
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
# -path and * in string add possibilty to find files like .bashrc
findf() {
# Find file or files, directories and links given as first parameter
# $* files, directories, links or strings
local NAME USAGE STRING
NAME='findf'
USAGE="$NAME file1 [file2 ...]"
if [ -n "$1" ]; then
for STRING in "$@"; do
eval find . -type f | grep $STRING
done
else
echo "Missing argument!"
echo "Usage: $USAGE"
fi
}
findd() {
# Find directories given as first parameter
# $* directories or strings
local NAME USAGE STRING
NAME='findd'
USAGE="$NAME dir1 [dir2 ...]"
if [ -n "$1" ]; then
for STRING in "$@"; do
eval find . -type d | grep $STRING
done
else
echo "Missing argument!"
echo "Usage: $USAGE"
fi
}
findl() {
# Find symbolic links given as first parameter
# $* links or strings
local STRING NAME
NAME='findl'
USAGE="$NAME link1 [link2 ...]"
if [ -n "$1" ]; then
for STRING in "$@"; do
eval find . -type l | grep $STRING
done
else
echo "Missing argument!"
echo "Usage: $USAGE"
fi
}