bash - bash unzip 保留部分目录结构
问题描述
客户从客户的 OUTPUT 目录提交带有目录结构的大型(1.5gigs,>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
可能无法在一个衬里中完成,但还没有找到任何脚本可以在部分目录中读取几千个文件,然后将它们解压缩到特定目录。
有什么想法吗?
解决方案
推荐阅读
- android - 如何创建扩展函数来调整 Kotlin 中的图像大小?
- javascript - 我正在用 node.js 制作一个不和谐的音乐机器人,它有点工作,但没有加入 vc 或播放歌曲
- mysql - 如何将参数传递给 Sequelize 模型中的 getter?
- blockchain - 我想控制 Corda 中 liquibase 下的现有数据库。我正在使用 xml 格式的 liquibase
- macos - 如何在 SwiftUI 上将 NSColor 转换为 Color,反之亦然
- kubernetes - 无法在 Istio 代理后面的 k8s 中建立与 VerneMQ 集群的 mqtt 连接
- scala - 使用下划线作为标识符时,隐式模式定义不绑定任何变量
- android - Android 构建失败并出现第 3 方库的重复类错误
- forms - Symfony 验证错误后返回空表单
- analytics - 为表创建浮动最大值