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