#!/bin/bash
# 概要文件类型自动解压
ftype=`file "$1"`
case "$ftype" in
"$1: Zip archive"*)
if [ -z "$2" ]; then
unzip "$1"
else
unzip "$1" -d "$2"
fi
;;
"$1: gzip compressed"*)
if [ -z "$2" ]; then
tar -zxvf "$1"
else
tar -zxvf "$1" -C "$2"
fi
;;
"$1: bzip2 compressed"*)
if [ -z "$2" ]; then
tar -jxvf "$1"
else
tar -jxvf "$1" -C "$2"
fi
;;
*) echo "File $1 can not be uncompressed with smartzip";;
esacLinux Smart 解压文件
最新推荐文章于 2026-04-25 02:02:43 发布
本文介绍了一个用于自动识别并解压不同类型压缩文件的bash脚本。该脚本能够根据文件类型选择合适的解压方式,支持ZIP、GZIP及BZIP2等常见压缩格式。
579

被折叠的 条评论
为什么被折叠?



