解壓文件夾中所有 rar
文件,並保持文件目錄結構不變
# !/bin/bash
src_path=`readlink -f $1`
dst_path=`readlink -f $2`
rar_files=`find $src_path -name '*.rar'`
IFS=$'\n'; array=$rar_files; unset IFS
for rar_file in $array; do
file_path=`echo $rar_file | sed -e "s;$src_path;$dst_path;"`
ext_path=${file_path%/*}
if [ ! -d $ext_path ]; then
mkdir -p $ext_path
fi
unrar x $rar_file $ext_path
done
其中,第一個參數爲rar
所在文件夾,第二個參數爲解壓路徑。