- #!/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
- #该片段来自于http://www.codesnippet.cn/detail/2310201513888.html
来源: http://www.codesnippet.cn/detail/2310201513888.html