Linux解压指定目录下zip和rar文件

来源:互联网 发布:C 释放动态数组内存 编辑:程序博客网 时间:2024/06/06 03:09
#!/bin/bash


function unzip_file(){
echo "$1"
for file in `ls $1 `
    do
        if [ -d $1"/"$file ] 
        then
            unzip_file $1"/"$file
        else
        if [ "${file##*.}"x = "zip"x ];then
        temp_file=$1"/"$file 
#filelist[$i]="$temp_file"
        unzip $temp_file -d $1
        fi
        if [ "${file##*.}"x = "rar"x ];then
        temp_file=$1"/"$file
        #filelist[$i]="$temp_file"
        unrar e temp_file $1
        fi
       
        fi
    done
}
unzip_file $1
0 0