-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsearch_all
53 lines (49 loc) · 1.05 KB
/
search_all
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
maven_expr(){
local expr="-iname '*$1*.jar'"
shift
for i in $*
do
expr="${expr} -a -iname '*${i}*.jar'"
done
expr="find ~/.m2 -type f \( `echo ${expr}` \) | sed 's/\/[0-9].*\/.*.jar//g' | uniq "
echo "$expr"
}
gradle_expr(){
local expr="-iname '*$1*'"
shift
for i in $*
do
expr="${expr} -a -iname '*${i}*'"
done
expr="find ~/.gradle/caches/modules-2/files-2.1 -type d \( `echo ${expr}` \) | grep -vE '\.[a-zA-Z]+$' "
echo "$expr"
}
search_all(){
echo "{ \"items\":["
separator=""
if [ $# -eq 0 ];then
echo "{"
echo "\"title\": \"请输入要查找的jar包名称\","
echo "}"
echo "]}"
exit
fi
expr1=$(maven_expr $*)
expr2=$(gradle_expr $*)
a=$(eval $expr1)
b=$(eval $expr2)
echo $a\\n$b |grep -vE "^$" | sort| uniq | while read line
do
line=${line##*/}
echo ${separator}
separator=","
echo "{"
echo "\"uid\": \"${line}\","
echo "\"type\": \"file\","
echo "\"title\": \"${line}\","
echo "\"arg\": \"${line}\""
echo "}"
done
echo "]}"
}
search_all $*