$1 compressed file
$2 dest path
function decompressandcopy()
{
filepath=`echo $1 | sed 's/[^\/]*$//'`
不是/字符直到末尾,*表示可以是0
因此/PATH1/PATH2/输出也是对的
#if filepath + tmp exist
filetemppath=$filepath"tmp/"
echo "filetemppath $filetemppath"
if [ ! -d "$filetemppath" ]; then
mkdir -p "$filetemppath"
else
echo "tmpfilepaht already exist: $filetemppath"
fi
#if exist
if [ -d "$filetemppath" ]; then
tar -zxvf $1 -C $filetemppath
if [ ! $? == 0 ]; then
echo "tar -zxvf $filetemppath failed"
return 1
fi
fi
filelists=`ls $filetemppath`
for tmpfile in $filelists
do
if [ ! "$tmpfile" == "" ]; then
echo "move $filetemppath$tmpfile to $2 "
mv $filetemppath$tmpfile $2
fi
done
}
posted on 2014-07-02 12:19
pizzx 阅读(111)
评论(0) 编辑 收藏 引用