Automatically generate script header format and invoke Vim tool

Source: Internet
Author: User

When we write the script, we always start to define the script header format according to the script writing specification, the time is not likely to feel the trouble is inefficient, here is to introduce a good idea to everyone.

1 First we in VIM first copy the content of the head format, here to copy a two senior format, to modify their own information can be.

1#!/bin/Bash2# ----------------+---------------------------------------+3# *Author:yongmouchen4# * Revision:2.05# * Email:6303609@qq. com6# * Create Time: D= 'Date+%f ', t= 'Date+%T '7# * blogaddress:www.cnblogs.com/chenyongmou/8# * Filename: 'basename$1`9# *Description:Ten# ----------------+---------------------------------------+

The above content can be changed according to their own preferences.

2 We want to implement a run this script and then automatically generate the head, and call the Vim tool, the end of the article with EOF end, you need to use the cat command

1#!/bin/Bash2 3 4 Cat> $1<<EOF5#!/bin/Bash6# ----------------+---------------------------------------+7# *Author:yongmouchen8# * Revision:2.09# * Email:6303609@qq. comTen# * Create Time: D= 'Date+%f ', t= 'Date+%T ' One# * blogaddress:www.cnblogs.com/chenyongmou/ A# * Filename: 'basename$1` -# *Description: -# ----------------+---------------------------------------+ the  - EOF -Vim + $1

In order for the first cursor after the script to be run to rest below the head, a space is added to the front of EOF.

3 So the small script is finished, and then save the script name xxxx.sh, and to give this sh plus execute permissions to the variable directory, each time you want to create a new script, you can xxxx.sh name.sh to create a new script and

The head is imported.

Does it feel good to use?

Automatically generate script header format and invoke Vim tool

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.