@@ -23,20 +23,28 @@ The pattern default is *extended* regex.
2323
2424Example:
2525 ${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
2727 ${PROG} 'log4j\.properties$' -d /path/to/find/directory
2828 ${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 ' <-> '
2931
30- Options :
32+ Find control :
3133 -d, --dir the directory that find jar files, default is current directory.
3234 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.
3437 -E, --extended-regexp PATTERN is an extended regular expression (*default*)
3538 -F, --fixed-strings PATTERN is a set of newline-separated strings
3639 -G, --basic-regexp PATTERN is a basic regular expression
3740 -P, --perl-regexp PATTERN is a Perl regular expression
3841 -i, --ignore-case ignore case distinctions
42+
43+ Output control:
3944 -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:
4048 -h, --help display this help and exit
4149EOF
4250
@@ -57,6 +65,10 @@ while [ $# -gt 0 ]; do
5765 dirs=(" ${dirs[@]} " " $2 " )
5866 shift 2
5967 ;;
68+ -e|--extension)
69+ extension=(" ${extension[@]} " " $2 " )
70+ shift 2
71+ ;;
6072 -s|--seperator)
6173 seperator=" $2 "
6274 shift 2
@@ -105,6 +117,7 @@ while [ $# -gt 0 ]; do
105117 esac
106118done
107119dirs=${dirs:- .}
120+ extension=${extension:- jar}
108121seperator=" ${seperator:-! } "
109122
110123[ " ${# args[@]} " -eq 0 ] && { echo " No find file pattern!" 1>&2 ; usage 1; }
@@ -122,6 +135,14 @@ $use_absolute_path && {
122135 dirs=( " ${tmp_dirs[@]} " )
123136}
124137
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+
125146# ###############################################################################
126147# Check the existence of command for listing zip entry!
127148# ###############################################################################
@@ -194,7 +215,7 @@ clearResponsiveMessage() {
194215# find logic
195216# ###############################################################################
196217
197- readonly jar_files=" $( find " ${dirs[@]} " -iname ' *.jar ' -type f) "
218+ readonly jar_files=" $( find " ${dirs[@]} " " ${find_iname_options[@]} " -type f) "
198219readonly total_count=" $( echo " $jar_files " | wc -l) "
199220[ -z " $jar_files " ] && {
200221 echo " No jar found!" 1>&2
0 commit comments