forked from gregorgorjanc/GorjancShell
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfunc_find.sh
70 lines (61 loc) · 1.58 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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# FIND*
#-------------------------------------------------------------------------------
# Function findf finds file or files, maps and links, which should be given
# as first paramter. findd finds maps, findl finds symbolic links
# -path and * in string add possibilty to find files like .bashrc
# $* - files, maps, links or strings
# Usage: findf bash [ diary ... ]
# My-time-stamp: <2016-03-08 ggorjanc>
findf()
{
local STRING NAME HITS TMP TMP2
NAME='findf'
USAGE="$NAME file1 [file2 ...]"
if [ -n "$1" ]; then
for STRING in $*; do
eval find . -type f -path \"*${STRING}*\"
# HITS=$(eval find . -path \"*${STRING}*\")
# for i in $HITS; do
# TMP=$(basename $i)
# TMP2=$(echo $TMP | grep $STRING)
# if [ -n "$TMP2" ]; then
# echo $i
# fi
# done
done
else
echo "Missing argument!"
echo "Usage: $USAGE"
fi
}
export -f findf
findd()
{
local STRING NAME
NAME='findd'
USAGE="$NAME map1 [map2 ...]"
if [ -n "$1" ]; then
for STRING in $*; do
eval find . -type d -path \"*${STRING}*\"
done
else
echo "Missing argument!"
echo "Usage: $USAGE"
fi
}
export -f findd
findl()
{
local STRING NAME
NAME='findl'
USAGE="$NAME link1 [link2 ...]"
if [ -n "$1" ]; then
for STRING in $*; do
eval find . -type l -path \"*${STRING}*\"
done
else
echo "Missing argument!"
echo "Usage: $USAGE"
fi
}
export -f findl