A simple script that automatically creates shell scripts

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.