你问的 “CentOS extract” 我理解你可能是想说 在 CentOS 下对文件进行解压(extract)操作,能否批量配置/批量处理。下面分几种常见情况说明:
.tar.gzfor f in *.tar.gz; do
tar -zxvf "$f"
done
.zipfor f in *.zip; do
unzip "$f"
done
mkdir -p /data/extract
for f in *.tar.gz; do
tar -zxvf "$f" -C /data/extract
done
find 批量解压(子目录也处理)find . -name "*.tar.gz" -exec tar -zxvf {} \;
或解压到对应目录:
find . -name "*.zip" -exec sh -c 'unzip "$1" -d "${1%.zip}"' _ {} \;
✅ 可以,常见做法有:
#!/bin/bash
SRC_DIR=/data/backup
DST_DIR=/data/extract
for f in $SRC_DIR/*.tar.gz; do
tar -zxvf "$f" -C $DST_DIR
done
cron 定时批量解压0 2 * * * /opt/scripts/extract.sh
xargs 提高性能ls *.tar.gz | xargs -n1 -P4 tar -zxvf
(-P4 表示 4 个并行)
yum install -y unzip tar
tar -zxvf "$f" >> extract.log
如果你说的 “extract” 是指 某个具体软件 / 命令(如 extract 命令、Ansible、配置管理工具),可以补充一下场景,我可以给你更精确的答案。