Java Learing
Java Learing

Reputation: 271

How to copy folder from .jar file using shell script

I have jar file ex: sample.jar under this jar file there is a folder structure ex: "environment/xyz.properties" and "environment/abc.properties".

My Requirement: I need to copy entire "environment" folder with all property files and past in some other (ex: /tmp/environment)location using shell script.

Please help how to do copy folder from .jar using shell script.

Upvotes: 0

Views: 2080

Answers (2)

Oo.oO
Oo.oO

Reputation: 13375

struct
├── a
│   └── file_a.txt
├── b
│   └── file_b.txt
└── c
    └── file_c.txt

Create jar

jar cf struct.jar ./struct

Extract dir

jar xf struct.jar struct/a

After file is extracted you can do whatever you like:

jar xf struct.jar struct/a
cp -r struct/a /tmp/environment

Upvotes: 1

gnunix
gnunix

Reputation: 15

From what I understand you want to copy a directory in a shell,

so you type

cp -R /path/to/directory /path/to/other/location/

Upvotes: 0

Related Questions