File tree Expand file tree Collapse file tree 2 files changed +11
-2
lines changed
Expand file tree Collapse file tree 2 files changed +11
-2
lines changed Original file line number Diff line number Diff line change 2020- [ :beer : find-in-jars] ( #beer-find-in-jars )
2121 - [ 用法] ( #%E7%94%A8%E6%B3%95-2 )
2222 - [ 示例] ( #%E7%A4%BA%E4%BE%8B-2 )
23+ - [ 运行效果] ( #%E8%BF%90%E8%A1%8C%E6%95%88%E6%9E%9C )
2324 - [ 参考资料] ( #%E5%8F%82%E8%80%83%E8%B5%84%E6%96%99 )
2425
2526<!-- END doctoc generated TOC please keep comment here to allow auto update -->
@@ -399,6 +400,12 @@ WEB-INF/lib/aspectjweaver-1.8.8.jar!org/aspectj/weaver/XlintDefault.properties
399400......
400401` ` `
401402
403+ # ## 运行效果
404+
405+ 支持彩色输出,文件名中的匹配部分以` grep` 的高亮方式显示。
406+
407+ ! [](https://user-images.githubusercontent.com/1063891/33545067-9eb66072-d8a2-11e7-8a77-d815c0979e5e.gif)
408+
402409# ## 参考资料
403410
404411[在多个Jar(Zip)文件查找Log4J配置文件的Shell命令行](http://oldratlee.com/458/tech/shell/find-file-in-jar-zip-files.html)
Original file line number Diff line number Diff line change @@ -185,15 +185,17 @@ readonly total_count="$(echo "$jar_files" | wc -l)"
185185 exit 1
186186}
187187
188+ $is_console && readonly grep_color_option=' --color=always'
189+
188190counter=1
189191while read jar_file; do
190192 printResponsiveMessage " finding in jar($(( counter++ )) /$total_count ): $jar_file "
191193
192- $command_for_list_zip " ${jar_file} " | grep $regex_mode $ignore_case_option " $pattern " | while read file; do
194+ $command_for_list_zip " ${jar_file} " | grep $regex_mode $ignore_case_option $grep_color_option -- " $pattern " | while read file; do
193195 clearResponsiveMessage
194196
195197 $is_console &&
196- echo " $ec [1;31m${jar_file} $eend " \! " $ec [1;32m$ {file}$eend " ||
198+ echo " $ec [1;31m${jar_file} $eend$ec [1;32m" \! " $eend $ {file}" ||
197199 echo " ${jar_file} " \! " ${file} "
198200 done
199201
You can’t perform that action at this time.
0 commit comments