I'm trying to do what I specified in the object. I have a tar.gz archive (i.e. archive.tar.gz) and I want to:
- extract only some file (e.g. *.csv) contained in a specific folder of the archive (e.g. CSV_DIR).
- create a new tar.gz archive containing only files extracted in the previous step.
I can do that easily creating a temporary subdirectory with this bash instructions:
tar -xzf archive.tar.gz --xform='s#^.+/##x' --wildcards -C /path/to/subdir "**/CSV_DIR/*csv"
tar -czf csvarchive.tar.gz -C /path/to/dir .
My question is, how can I do that piping the output of the first instruction to the second one?
I tried something like:
tar -xzf archive.tar.gz --xform='s#^.+/##x' --wildcards "**/CSV_DIR/*csv" | tar -czf csvarchive.tar.gz -T -
But the archive created is empty.
Some suggestions?