Issue
I have a .tar.gz file which has multiple folders underneath. Each folder has multiple files and I only want to extract the SNAPSHOT.jar from all the folders it has underneath.
I tried using wildcards but its not helping. Ex:
tar -xf samplejars.tar.gz --wildcards "*SNAPSHOT*.jar"
samplejars.tar.gz has many folders and I only want to extract SNAPSHOT.jar. How do I do that?
Note: All the jars have unique/different names.
Solution
I tested it with the following folder structure:
data/
data/a
data/a/ANOTHER_SNAPSHOT.jar
data/b
data/c
data/c/SNAPSHOT.jar
data/d
data/e
data/f
data/f/SNAPSHOT.jar.with.extension
data/g
data/g/SNAPSHOT.jar
data/h
The following wildcard mask works and extract only the files matching exactly SNAPSHOT.jar not SNAPSHOT.jar.with.extension and ANOTHER_SNAPSHOT.jar
tar -xf data.tar.gz --wildcards "*/SNAPSHOT.jar"
Result:
data/c/SNAPSHOT.jar
data/g/SNAPSHOT.jar
Answered By - Florian Schlag Answer Checked By - Robin (WPSolving Admin)