歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux基礎 >> Linux教程 >> Linux Smart 解壓文件

Linux Smart 解壓文件

日期:2017/2/28 16:03:31   编辑:Linux教程
#!/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";;
esac
Copyright © Linux教程網 All Rights Reserved