Search code examples
linuxshellunixjarunzip

unzip -d option to extract file from jar to specific directory


unzip -d option to extract file from jar to specific directory

Without using any option we can unzip specific file to same directory structure, but -d option doesn't seem to work.

unzip someNiceOne.jar com/some/comp/some/dir/name.properties

This will unzip file 'name.properties' to 'com/some/comp/some/dir/'.

I need 'name.properties' to be under same directory level where my jar is present, but -d option doesn't seem to work. Any alternative option?.

unzip -d option help :

-d extract files into exdir


Solution

  • Using -j option should do what you need.

    -j  junk paths (do not make directories)
    

    In your case:

    unzip -j someNiceOne.jar com/some/comp/some/dir/name.properties