shell获取当前工作目录绝对路径及压缩备份一个目录下的所有的文件

清华大佬耗费三个月吐血整理的几百G的资源,免费分享!....>>>

#!/bin/bash
this_dir=`pwd`
echo "$this_dir ,this is pwd"
echo "$0 ,this is \$0"
dirname $0|grep "^/" >/dev/null
if [ $? -eq 0 ];then
    this_dir=`dirname $0`
else
    dirname $0|grep "^\." >/dev/null
     retval=$?
if [ $retval -eq 0 ];then
    this_dir=`dirname $0|sed "s#^.#$this_dir#"`
else
    this_dir=`dirname $0|sed "s#^#$this_dir/#"`
fi
 fi
 echo $this_dir
date=`date +%Y%m%d%H%M` 
tar -czvf /root/test/FTP_DATA_$date.tar.gz /FTP_DATA