shell脚本
vim script.sh
#!/bin/bash
echo hello world
第一种执行方式
sh script.sh ##会自动忽略#!/bin/bash
第二中执行方式
chmod 775 script.sh
script.sh
vim /etc/vimrc
在最后添加以下内容
autocmd BufNewFile *.sh,*.script exec ":call Westos()" ##当用vim创建的新文件是以.sh,.script为后缀的文件时,自动添加注释信息
map <F4> ms:call Westos()<cr>'s ##按F4添加注释信息
func Westos()
call append(0,"######################################")
call append(1,"# Author: #")
call append(2,"# Date:".strftime("%Y-%m-%d %H:%M:%S").(" #"))
call append(3,"# Mail: #")
call append(4,"# Version: #")
call append(5,"# Description: #")
call append(6,"# #")
call append(7,"######################################")
call append(8,"")
call append(9,"#!/bin/bash")
call append(10,"")
endfunc
sh -x ##调试