Tuesday, 13 November 2018

Reminder - pulling a single file from a ZIP archive

I am following this tutorial: -


which requires one to download Apache Derby from here: -


specifically the LIB distribution ( which just provides the Apache runtime in a Java JAR file, rather than the full set of binaries ).

Having downloaded the required ZIP file: -


I wanted to simply extract the derby.jar file to my WebSphere Liberty Profile environment.

I navigated to the appropriate directory on the file-system: -

cd /Users/davidhay/wlp/usr/shared/resources

and then listed the contents of the downloaded ZIP fie: -

unzip -l ~/Downloads/db-derby-10.10.2.0-lib.zip

Archive:  /Users/davidhay/Downloads/db-derby-10.10.2.0-lib.zip
  Length      Date    Time    Name
---------  ---------- -----   ----
        0  03-27-2014 12:21   db-derby-10.10.2.0-lib/
    39891  03-27-2014 12:21   db-derby-10.10.2.0-lib/KEYS
    11560  03-27-2014 12:21   db-derby-10.10.2.0-lib/LICENSE
     7323  03-27-2014 12:21   db-derby-10.10.2.0-lib/NOTICE
    49122  03-27-2014 12:21   db-derby-10.10.2.0-lib/RELEASE-NOTES.html
        0  03-27-2014 12:21   db-derby-10.10.2.0-lib/lib/
  2838580  03-27-2014 12:15   db-derby-10.10.2.0-lib/lib/derby.jar
     1476  03-27-2014 12:15   db-derby-10.10.2.0-lib/lib/derby.war
    92470  03-27-2014 12:15   db-derby-10.10.2.0-lib/lib/derbyLocale_cs.jar
   104596  03-27-2014 12:15   db-derby-10.10.2.0-lib/lib/derbyLocale_de_DE.jar
    98708  03-27-2014 12:15   db-derby-10.10.2.0-lib/lib/derbyLocale_es.jar
   104718  03-27-2014 12:15   db-derby-10.10.2.0-lib/lib/derbyLocale_fr.jar
    93172  03-27-2014 12:15   db-derby-10.10.2.0-lib/lib/derbyLocale_hu.jar
    98556  03-27-2014 12:15   db-derby-10.10.2.0-lib/lib/derbyLocale_it.jar
   115193  03-27-2014 12:15   db-derby-10.10.2.0-lib/lib/derbyLocale_ja_JP.jar
   109610  03-27-2014 12:15   db-derby-10.10.2.0-lib/lib/derbyLocale_ko_KR.jar
    91165  03-27-2014 12:15   db-derby-10.10.2.0-lib/lib/derbyLocale_pl.jar
    88405  03-27-2014 12:15   db-derby-10.10.2.0-lib/lib/derbyLocale_pt_BR.jar
   119017  03-27-2014 12:15   db-derby-10.10.2.0-lib/lib/derbyLocale_ru.jar
   101533  03-27-2014 12:15   db-derby-10.10.2.0-lib/lib/derbyLocale_zh_CN.jar
   103118  03-27-2014 12:15   db-derby-10.10.2.0-lib/lib/derbyLocale_zh_TW.jar
   586237  03-27-2014 12:15   db-derby-10.10.2.0-lib/lib/derbyclient.jar
   252393  03-27-2014 12:15   db-derby-10.10.2.0-lib/lib/derbynet.jar
     7143  03-27-2014 12:15   db-derby-10.10.2.0-lib/lib/derbyrun.jar
   214415  03-27-2014 12:15   db-derby-10.10.2.0-lib/lib/derbytools.jar
        0  03-27-2014 12:21   db-derby-10.10.2.0-lib/test/
  7654758  03-27-2014 12:15   db-derby-10.10.2.0-lib/test/derbyTesting.jar
    81105  03-27-2014 09:35   db-derby-10.10.2.0-lib/test/README.htm
    65261  03-27-2014 09:31   db-derby-10.10.2.0-lib/test/jakarta-oro-2.0.8.jar
---------                     -------
 13129525                     29 files


( note that I've highlighted the JAR file that I actually want )

and then extracted JUSt that JAR file: -

unzip ~/Downloads/db-derby-10.10.2.0-lib.zip "db-derby-10.10.2.0-lib/lib/derby.jar""

Note that I've specifically referenced the full path of the compressed JAR file: -

db-derby-10.10.2.0-lib/lib/derby.jar

and wrapped it in double-quotes.

However, this retains the original path, so I end up with this: -

ls -R /Users/davidhay/wlp/usr/shared/resources

db-derby-10.10.2.0-lib

/Users/davidhay/wlp/usr/shared/resources/db-derby-10.10.2.0-lib:
lib

/Users/davidhay/wlp/usr/shared/resources/db-derby-10.10.2.0-lib/lib:
derby.jar

Thankfully, the unzip command allows me to "junk" that path: -

man unzip

       -j     junk paths.  The archive's directory structure is not recreated; all files are deposited in the extraction directory (by default, the current one).

so, having cleared up the directory: -

rm -Rf /Users/davidhay/wlp/usr/shared/resources/*

I then re-ran the unzip command: -

unzip -j ~/Downloads/db-derby-10.10.2.0-lib.zip "db-derby-10.10.2.0-lib/lib/derby.jar"

Archive:  /Users/davidhay/Downloads/db-derby-10.10.2.0-lib.zip
  inflating: derby.jar             

leaving me with this: -

ls -R /Users/davidhay/wlp/usr/shared/resources

derby.jar

Nice !

No comments:

Note to self - use kubectl to query images in a pod or deployment

In both cases, we use JSON ... For a deployment, we can do this: - kubectl get deployment foobar --namespace snafu --output jsonpath="{...