Because I usually write some small experimental script, every time to write author,description and so very troublesome, then wrote such a script can create their own small script, code as follows, pure personal original, relatively rough, big God do not spray
#!/bin/bash#ver=0aut=0tim=0des=1if [ $# -lt 1 ];then echo "' Basename $0 ' : -a|--author|-t|-d|-v|-f|--file /path/to/file| -H " exit 3fiwhile [ $# -ge 1 ]; Docase $1 in-v|--version) VER=1 shift ;; -H|--HELP) echo "' Basename $0 ' : -a|-- Author|-t|-d|-v|-f|--file /path/to/file|-h " exit 0 ;; -a|--author) AUT=1 shift ;; -t|--time)        &NBsp tim=1 shift 1 ;; -d|--description) DES=1 shift 1 ;; -f|--file) FIL=1 FILEPATH=$2 shift 2 ;; *) echo "' Basename $0 ' : -a|--author|-t|-d| -v|-f|--file /path/to/file|-h " exit 8esacdoneif [ $DES -eq 1 ];then read -p " Please input the scripts description: " DESCRIPTIONfiif [ $FIL -eq 1 ];then if [ -e $FILEPATH ]&>/dev/null;then echo "The file exists." exit 8elsedirname= ' dirname $FILEPATH ' [ ! - e $DIRNAME ] && mkdir $DIRNAME fi echo ' #!/bin/bash ' >> $FILEPATHfi [ $AUT -eq 1 ] && echo "# author:soy sauce" >> $FILEPATH [ $TIM -eq 1 ] && echo "# date: ' date +%f ' ' date +%h:%s '" >> $ filepath echo "# description: $DESCRIPTION" > > $FILEPATH [ $VER -eq 1 ] && echo "# version 1.0" >> $FILEPATH
Instructions for use:
1. Create a file called Mkscript under/usr/bin/, and then paste the code into it, save the exit
2. Add execute permissions to the script chmod +x/usr/bin/mkscript
PS: General Add execute permissions can be run directly, if the command is not found, check the local PATH environment variable
3. Commands use Syntax rules:
Mkscript--help
Mkscript:-a|–author|-t|-d|-v|-f|–file/path/to/file|-h
Eg:mkscript-a-t-d-v-f./back.sh
This article is from the "7589461" blog, please be sure to keep this source http://7599461.blog.51cto.com/7589461/1696126
A simple script that automatically creates shell scripts