在 Debian 里,“extract”通常有两种常见含义,我分别说明,你看看你指的是哪一种。
.tar / .tar.gz / .tar.xz#!/bin/bash
file="$1"
case "$file" in
*.tar)
tar -xvf "$file"
;;
*.tar.gz|*.tgz)
tar -xzvf "$file"
;;
*.tar.xz)
tar -xJvf "$file"
;;
*.zip)
unzip "$file"
;;
*.deb)
dpkg-deb -x "$file" ./extracted
;;
*)
echo "不支持的格式: $file"
;;
esac
保存为 extract.sh,然后:
chmod +x extract.sh
./extract.sh file.tar.gz
.deb 包(Debian 软件包)dpkg-deb -x package.deb output_dir
或只提取控制信息:
dpkg-deb -e package.deb control_dir
如果你是想要 从系统或软件包中提取信息(比如版本、依赖):
dpkg -l | grep nginx
.deb 包依赖dpkg-deb -f package.deb Depends
#!/bin/bash
echo "OS: $(lsb_release -d | cut -f2)"
echo "Kernel: $(uname -r)"
echo "Arch: $(dpkg --print-architecture)"
extract 命令本身Debian 默认没有 extract 命令,你可能指的是:
tarunzipdpkg-debar、bsdtar)如果你能补充一句:
我想用脚本 提取什么(文件 / 软件包 / 系统信息)?
我可以给你更精准的脚本。