I have a bunch of jar files lying in a folder. Lets name it /Users/labuser/jars
Each jar file has a manifest file in META_INF/MANIFEST.MF
I have to read each MANIFEST.MF file and get some information from it. So, instead of extracting whole jar, one by one is a tedius thing.
What I want
I want to extract that file in a folder whose name can be as of jar file.
Unzip command to extract a jar file
Following command can be used to unzip a complete jar file:
unzip <path of jar file>
If you want to unzip files to a particular folder
unzip <path of jar file> -d <path of target folder>
Note: if the target folder does not exists, it will be created
If you want to unzip only particular files
unzip <path of jar file> <path of file inside jar file>
If you want to unzip only particular files in a particular folder
unzip <path of jar file> <path of file inside jar file> -d <target folder>
That is all. Combine these, and you are done.
Shell script I used to solve this
for myfile in `ls /Users/labuser/jars` ; do unzip ../$myfile META-INF/MANIFEST.MF -d $myfile; done