1

I'm new in Unix, am trying to extract specific file(by using one command) form this kind of folder structure: .../file1.ear/file2.war/folder1/folder2/fileToExtract.txt

What I do now is extract the first ear file to a folder (unzip), then extract the second war file to a folder and only then I am able to open the txt file in Unix.

3

By combining unzip and jar, you can extract the various components using pipes:

unzip -p file1.ear file2.war | jar x folder1/folder2/fileToExtract.txt

The -p option to unzip instructs it to extract file2.war to its standard output, without anything else; then jar x reads file2.war from its standard input and extracts folder1/folder2/fileToExtract.txt.

Both tools in isolation aren't sufficient as far as I can determine: unzip can't read archives from its standard input, and jar can't extract to its standard output...

| improve this answer | |
0

You cold use mc (midnight commander). You can even edit the files without unpacking.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.