我列出了我的jar文件的内容,如下所示:
jar -tf myjar.jar
但我想有选择地列出,例如所有以'm'开头的文件。以下不起作用:
jar -tf myjar.jar m*
我可以列出文件夹中的所有文件:
jar -tf myjar.jar folder/
但不是以'm'开头的文件:
jar -tf myjar.jar folder/m*
我有办法过滤列出的文件吗?
答案 0 :(得分:0)
使用grep
或egrep
或类似的命令行实用程序,例如,
jar -tf myjar.jar | grep "folder/m"
jar
命令本身不支持此类操作。使用grep
/ egrep
/等工具是一种规范的解决方案,无论如何都是必不可少的工具。
答案 1 :(得分:0)
您可以使用find
命令和jar
命令。这不会为您提供文件名起始模式的确切结果,但您可以接近。
没有find
命令
C:\jdk1.7.0_72\jre\lib>jar -tf jce.jar
META-INF/MANIFEST.MF
META-INF/ORACLE_J.SF
META-INF/ORACLE_J.RSA
META-INF/
javax/crypto/
javax/crypto/ExemptionMechanismSpi.class
javax/crypto/CryptoPolicyParser$ParsingException.class
javax/crypto/CryptoPolicyParser$GrantEntry.class
javax/crypto/CryptoPolicyParser.class
javax/crypto/JceSecurity$1.class
javax/crypto/CryptoPermissions.class
javax/crypto/AEADBadTagException.class
javax/crypto/NullCipherSpi.class
javax/crypto/EncryptedPrivateKeyInfo.class
javax/crypto/ShortBufferException.class
javax/crypto/CipherInputStream.class
javax/crypto/SecretKey.class
javax/crypto/JarVerifier$JarHolder.class
javax/crypto/extObjectInputStream.class
javax/crypto/CipherSpi.class
javax/crypto/KeyGenerator.class
javax/crypto/JceSecurity$2.class
javax/crypto/interfaces/
javax/crypto/interfaces/PBEKey.class
javax/crypto/interfaces/DHPrivateKey.class
javax/crypto/interfaces/DHKey.class
javax/crypto/interfaces/DHPublicKey.class
javax/crypto/IllegalBlockSizeException.class
javax/crypto/CryptoPolicyParser$CryptoPermissionEntry.class
javax/crypto/Cipher$Transform.class
javax/crypto/MacSpi.class
javax/crypto/spec/
javax/crypto/spec/SecretKeySpec.class
javax/crypto/spec/DHParameterSpec.class
javax/crypto/spec/PBEParameterSpec.class
javax/crypto/spec/DHPublicKeySpec.class
javax/crypto/spec/RC5ParameterSpec.class
javax/crypto/spec/IvParameterSpec.class
javax/crypto/spec/RC2ParameterSpec.class
javax/crypto/spec/GCMParameterSpec.class
javax/crypto/spec/DHPrivateKeySpec.class
javax/crypto/spec/OAEPParameterSpec.class
javax/crypto/spec/PBEKeySpec.class
javax/crypto/spec/DESKeySpec.class
javax/crypto/spec/PSource.class
javax/crypto/spec/DHGenParameterSpec.class
javax/crypto/spec/DESedeKeySpec.class
javax/crypto/spec/PSource$PSpecified.class
javax/crypto/JceSecurityManager$1.class
javax/crypto/SecretKeyFactory.class
javax/crypto/ExemptionMechanismException.class
javax/crypto/BadPaddingException.class
javax/crypto/JceSecurity.class
javax/crypto/JarVerifier$2.class
javax/crypto/CryptoAllPermissionCollection.class
javax/crypto/NullCipher.class
javax/crypto/KeyAgreementSpi.class
javax/crypto/CryptoAllPermission.class
javax/crypto/KeyGeneratorSpi.class
javax/crypto/JarVerifier$1.class
javax/crypto/ExemptionMechanism.class
javax/crypto/JceSecurityManager.class
javax/crypto/KeyAgreement.class
javax/crypto/NoSuchPaddingException.class
javax/crypto/CryptoPermissionCollection.class
javax/crypto/PermissionsEnumerator.class
javax/crypto/Mac.class
javax/crypto/SealedObject.class
javax/crypto/Cipher.class
javax/crypto/CryptoPermission.class
javax/crypto/CipherOutputStream.class
javax/crypto/SecretKeyFactorySpi.class
javax/crypto/JarVerifier.class
sun/security/internal/interfaces/
sun/security/internal/interfaces/TlsMasterSecret.class
sun/security/internal/spec/
sun/security/internal/spec/TlsMasterSecretParameterSpec.class
sun/security/internal/spec/TlsKeyMaterialParameterSpec.class
sun/security/internal/spec/TlsKeyMaterialSpec.class
sun/security/internal/spec/TlsRsaPremasterSecretParameterSpec$1.class
sun/security/internal/spec/TlsPrfParameterSpec.class
sun/security/internal/spec/TlsRsaPremasterSecretParameterSpec.class
使用find
命令:
C:\jdk1.7.0_72\jre\lib>jar -tf jce.jar | find "Key"
javax/crypto/EncryptedPrivateKeyInfo.class
javax/crypto/SecretKey.class
javax/crypto/KeyGenerator.class
javax/crypto/interfaces/PBEKey.class
javax/crypto/interfaces/DHPrivateKey.class
javax/crypto/interfaces/DHKey.class
javax/crypto/interfaces/DHPublicKey.class
javax/crypto/spec/SecretKeySpec.class
javax/crypto/spec/DHPublicKeySpec.class
javax/crypto/spec/DHPrivateKeySpec.class
javax/crypto/spec/PBEKeySpec.class
javax/crypto/spec/DESKeySpec.class
javax/crypto/spec/DESedeKeySpec.class
javax/crypto/SecretKeyFactory.class
javax/crypto/KeyAgreementSpi.class
javax/crypto/KeyGeneratorSpi.class
javax/crypto/KeyAgreement.class
javax/crypto/SecretKeyFactorySpi.class
sun/security/internal/spec/TlsKeyMaterialParameterSpec.class
sun/security/internal/spec/TlsKeyMaterialSpec.class