bash解压缩保留部分目录结构

时间:2020-05-24 14:33:11

标签: bash unzip

客户从客户OUTPUT目录提交大型(1.5gig,> 10,000个文件)的zip文件及其目录结构。
我想将bash解压缩到我的INPUT目录,同时也保留它们的目录结构,但不要整个目录结构。

例如,如果他们的zip文件包含以下文件:

/home/base/data/output/able/file1.xml
/home/base/data/output/able/file2.xml
/home/base/data/output/able/file3.xml
/home/base/data/output/baker/file1.xml
/home/base/data/output/baker/file2.xml
/home/base/data/output/baker/file3.xml
/home/base/data/output/charlie/file1.xml
/home/base/data/output/charlie/file2.xml
/home/base/data/output/charlie/file3.xml
(this goes on for thousands of files in about a dozen unique directories)

我想将它们解压缩到我的INPUT目录中,如下所示:

../input/able/file1.xml
../input/able/file2.xml
../input/able/file3.xml
../input/baker/file1.xml
../input/baker/file2.xml
../input/baker/file3.xml
../input/charlie/file1.xml
../input/charlie/file2.xml
../input/charlie/file3.xml

到目前为止,我已经尝试过:

unzip BIGFILE.zip   /output/   input   --(*) before and after /output/

它将解压缩具有able/baker/charlie等目录结构的所有xml文件。
但是,它还会在/output之前解压缩整个文件结构:

../input/home/base/data/output/able/file1.xml
../input/home/base/data/output/able/file2.xml
../input/home/base/data/output/able/file3.xml
../input/home/base/data/output/baker/file1.xml
../input/home/base/data/output/baker/file2.xml
../input/home/base/data/output/baker/file3.xml
../input/home/base/data/output/charlie/file1.xml
../input/home/base/data/output/charlie/file2.xml
../input/home/base/data/output/charile/file3.xml

可能无法在一个内衬中完成,但是还没有找到可以在部分目录中读取数千个文件,然后将其解压缩到特定目录的脚本。
有什么想法吗?

0 个答案:

没有答案