newscript.sh


#!/bin/bash
#
while getopts ":a:b:" SWITCH ; do
  case $SWITCH in
  a)
   AUTHOR=$OPTARG ;;
  b)
   DESC=$OPTARG ;;
 \:)
   echo "Unkown options."
   exit 1
  ;;
  esac
done
shift $[$OPTIND-1]
if ! grep "#!/bin/bash" $1 &> /dev/null; then
cat>> $1 <<EOF
#!/bin/bash
# Description: ${DESC}
# Date: `date +"%F %T"`
# Author: ${AUTHOR:=XSG}
# Version: 0-0-0

EOF
fi
vim +6 $1
wait
chmod u+x $1

你可能感兴趣的:(职场,bash,script,bin,休闲)