@@ -23,20 +23,28 @@ The pattern default is *extended* regex.
23
23
24
24
Example:
25
25
${PROG} 'log4j\.properties'
26
- ${PROG} '^log4j(\. properties|\. xml)$' # search file log4j.properties/log4j.xml at zip root
26
+ ${PROG} '^log4j\.( properties|xml)$' # search file log4j.properties/log4j.xml at zip root
27
27
${PROG} 'log4j\.properties$' -d /path/to/find/directory
28
28
${PROG} 'log4j\.properties' -d /path/to/find/dir1 -d /path/to/find/dir2
29
+ ${PROG} 'log4j\.properties' -e jar -e zip
30
+ ${PROG} 'log4j\.properties' -s ' <-> '
29
31
30
- Options :
32
+ Find control :
31
33
-d, --dir the directory that find jar files, default is current directory.
32
34
this option can specify multiply times to find in multiply directories.
33
- -s, --seperator seperator for jar file and file entry, default is \` !'.
35
+ -e, --extension set find file extension, default is jar.
36
+ this option can specify multiply times to find in multiply extension.
34
37
-E, --extended-regexp PATTERN is an extended regular expression (*default*)
35
38
-F, --fixed-strings PATTERN is a set of newline-separated strings
36
39
-G, --basic-regexp PATTERN is a basic regular expression
37
40
-P, --perl-regexp PATTERN is a Perl regular expression
38
41
-i, --ignore-case ignore case distinctions
42
+
43
+ Output control:
39
44
-a, --absolute-path always print absolute path of jar file
45
+ -s, --seperator seperator for jar file and file entry, default is \` !'.
46
+
47
+ Miscellaneous:
40
48
-h, --help display this help and exit
41
49
EOF
42
50
@@ -57,6 +65,10 @@ while [ $# -gt 0 ]; do
57
65
dirs=(" ${dirs[@]} " " $2 " )
58
66
shift 2
59
67
;;
68
+ -e|--extension)
69
+ extension=(" ${extension[@]} " " $2 " )
70
+ shift 2
71
+ ;;
60
72
-s|--seperator)
61
73
seperator=" $2 "
62
74
shift 2
@@ -105,6 +117,7 @@ while [ $# -gt 0 ]; do
105
117
esac
106
118
done
107
119
dirs=${dirs:- .}
120
+ extension=${extension:- jar}
108
121
seperator=" ${seperator:-! } "
109
122
110
123
[ " ${# args[@]} " -eq 0 ] && { echo " No find file pattern!" 1>&2 ; usage 1; }
@@ -122,6 +135,14 @@ $use_absolute_path && {
122
135
dirs=( " ${tmp_dirs[@]} " )
123
136
}
124
137
138
+ # convert to find -iname options
139
+ for e in " ${extension[@]} " ; do
140
+ [ 0 -eq " ${# find_iname_options[@]} " ] &&
141
+ find_iname_options=( -iname " *.$e " ) ||
142
+ find_iname_options=( " ${find_iname_options[@]} " -o -iname " *.$e " )
143
+ done
144
+
145
+
125
146
# ###############################################################################
126
147
# Check the existence of command for listing zip entry!
127
148
# ###############################################################################
@@ -194,7 +215,7 @@ clearResponsiveMessage() {
194
215
# find logic
195
216
# ###############################################################################
196
217
197
- readonly jar_files=" $( find " ${dirs[@]} " -iname ' *.jar ' -type f) "
218
+ readonly jar_files=" $( find " ${dirs[@]} " " ${find_iname_options[@]} " -type f) "
198
219
readonly total_count=" $( echo " $jar_files " | wc -l) "
199
220
[ -z " $jar_files " ] && {
200
221
echo " No jar found!" 1>&2
0 commit comments