Firstly, a simple example:
for %i in (dir/b/s *.jar) do 7z l %i | findstr XDatabase.class
Result:
- D:\shared\xsql>for %i in (dir/b/s *.jar) do 7z l %i |findstr XDatabase.class
- D:\shared\xsql>7z l dir/b/s | findstr XDatabase.class
- D:\shared\xsql>7z l db2jcc.jar | findstr XDatabase.class
- D:\shared\xsql>7z l db2jcc_license_cu.jar | findstr XDatabase.class
- D:\shared\xsql>7z l jconn3.jar | findstr XDatabase.class
- D:\shared\xsql>7z l jodbc.jar | findstr XDatabase.class
- D:\shared\xsql>7z l jTDS3.jar | findstr XDatabase.class
- D:\shared\xsql>7z l mlscript.jar | findstr XDatabase.class
- D:\shared\xsql>7z l msbase.jar | findstr XDatabase.class
- D:\shared\xsql>7z l mssqlserver.jar | findstr XDatabase.class
- D:\shared\xsql>7z l msutil.jar | findstr XDatabase.class
- D:\shared\xsql>7z l mysql-connector-java-5.1.6-bin.jar | findstr XDatabase.class
- D:\shared\xsql>7z l ojdbc14.jar | findstr XDatabase.class
- D:\shared\xsql>7z l postgresql-8.4-701.jdbc4.jar | findstr XDatabase.class
- D:\shared\xsql>7z l sqlite.jar | findstr XDatabase.class
- D:\shared\xsql>7z l sqlitejdbc-v056-zentus.jar | findstr XDatabase.class
- D:\shared\xsql>7z l sqljdbc.jar | findstr XDatabase.class
- D:\shared\xsql>7z l ULjDatabaseTransfer.jar | findstr XDatabase.class
- D:\shared\xsql>7z l UltraLiteJ.jar | findstr XDatabase.class
- D:\shared\xsql>7z l UltraLiteJ12.jar | findstr XDatabase.class
- [b]D:\shared\xsql>7z l xsql.jar | findstr XDatabase.class
- 2010-12-24 21:05:40 ..... 30863 14443 [/b]com\sean\db\XDatabase.class
Summary:
We can write a batch cmd, together with 7z.exe, 7z.dll, like:
- @echo off
- SETLOCAL
- set WHICH_CLASS=%1
- echo WHICH_CLASS=%WHICH_CLASS%
- for /F %%i in ('dir /A:-D /S /B *.jar') do 7z l %%i | findstr %WHICH_CLASS% && echo %WHICH_CLASS% found in: "%%i"
- echo "Finished class finding..."
- echo "======================================"
- ENDLOCAL
See an example:
findclass com\\sybase\\afx\\util\\StringUtil.class
WHICH_CLASS=com\\sybase\\afx\\util\\StringUtil.class
2012-02-27 13:14:36 ..... 15230 5915 com\sybase\afx\util\StringUtil.class
com\\sybase\\afx\\util\\StringUtil.class found in: "U:\target\lib\ext\sup-client.jar"
2012-02-27 13:14:36 ..... 15230 5915 com\sybase\afx\util\StringUtil.class
com\\sybase\\afx\\util\\StringUtil.class found in: "U:\target\lib\ext\sup-server-rt.jar"
"Finished class finding..."
"======================================"
WHICH_CLASS=com\\sybase\\afx\\util\\StringUtil.class
2012-02-27 13:14:36 ..... 15230 5915 com\sybase\afx\util\StringUtil.class
com\\sybase\\afx\\util\\StringUtil.class found in: "U:\target\lib\ext\sup-client.jar"
2012-02-27 13:14:36 ..... 15230 5915 com\sybase\afx\util\StringUtil.class
com\\sybase\\afx\\util\\StringUtil.class found in: "U:\target\lib\ext\sup-server-rt.jar"
"Finished class finding..."
"======================================"
If you are interested in the source code of 7-zip, you can modify the source code and make it output the source file path when using
7z l <%%i> | findstr .....
It's very useful in your java project or java diagnostics work.
没有评论:
发表评论