解压文件夹中所有 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
所在文件夹,第二个参数为解压路径。