unzipfun
#!/bin/bash #auther by wangxp function unzipfun { if test $# -ne 2;then echo 'unzipfun $filename $filedir' exit 1 fi if test ! -f $1;then echo "$1 is not exist" exit 1 fi if test ! -d $2;then echo "$2 is not exist" exit 1 fi if test -z "`rpm -qa unzip`";then echo "unzip is not installed" exit 1 fi echo "$1 解压至目录 $2" unzip -qo $1 -d $2 >/dev/null 2>&1 & index=0 total=`unzip -l $1|tail -n 1|awk '{print $2}'` str='' while [ $index -lt 100 ] do current_t=`ls -aRl $2|grep ^[d,-]|wc -l` current_d=`ls -Rl $2|grep ^d|wc -l` current=$[$current_t-2*$current_d-2] for (( i=$index; i< $[$current*100/$total]; i++ )) do str+='#' done sleep 0.5 index=$[$current*100/$total] printf "[%-100s]\t[%3d%%]\r" $str $index done echo -e "\n解压完成" }