创建一脚本newscript
时间:2010-12-27 来源:《一剑》飘香
本文系作者原创,转载请保留出处:http://skyai1.cublog.cn
其中理解可能也有不当之处,欢迎各位指正。
创建一脚本‘newscript’以实现每次进行shell编程时减少工作量:如newscript -a(指明作者) -d(描述信息) file.sh #!/bin/bash usage() {
echo "Uknown options,Usage:`basename $0` [-a] [-d] filename"
exit 1
} while getopts ":a:d:" SWITCH ;do
case $SWITCH in
a)
AUTHOR=$OPTARG
;;
d)
DESC=$OPTARG
\?)
usage
;;
esac
done shift $[$OPTIND-1] if ! grep "^#!/bin/bash" $1 &>/dev/null ; then
cat >> $1 << EOF
#!/bin/bash
# Author:${AUTHOR:=AIDA_ZYF}
# Date & Time:`date +"%F %T"`
# Description:$DESC
# Version:`uname -r` EOF
fi
vim +7 $1 wait
chmod u+x $1
创建一脚本‘newscript’以实现每次进行shell编程时减少工作量:如newscript -a(指明作者) -d(描述信息) file.sh #!/bin/bash usage() {
echo "Uknown options,Usage:`basename $0` [-a] [-d] filename"
exit 1
} while getopts ":a:d:" SWITCH ;do
case $SWITCH in
a)
AUTHOR=$OPTARG
;;
d)
DESC=$OPTARG
\?)
usage
;;
esac
done shift $[$OPTIND-1] if ! grep "^#!/bin/bash" $1 &>/dev/null ; then
cat >> $1 << EOF
#!/bin/bash
# Author:${AUTHOR:=AIDA_ZYF}
# Date & Time:`date +"%F %T"`
# Description:$DESC
# Version:`uname -r` EOF
fi
vim +7 $1 wait
chmod u+x $1
相关阅读 更多 +