[root@centos7 ~]# cat createuser.sh
set -e
set -u
read -p "please input your username:" USER
if id $USER &> /dev/null;then
echo -e "\e[1;33m This user was created \e[0m"
elif useradd $USER;then
cat /etc/passwd |grep "$USER"
else
echo -e "\e[1;31m EORROR \e[0m"
fi
5、编写生成脚本基本格式的脚本,包括作者,联系方式,版本,时间,描述等
[root@centos7 ~]#vim .vimrc
set ignorecase
set cursorline
set autoindent
autocmd BufNewFile *.sh exec ":call SetTitle()"
func SetTitle()
if expand("%:e") == 'sh'
call setline(1,"#!/bin/bash")
call setline(2,"#")
call setline(3,"#********************************************************************")
call setline(4,"#Author: mazhiyuan")
call setline(5,"#QQ: 1209543044")
call setline(6,"#Date: ".strftime("%Y-%m-%d"))
call setline(7,"#FileNameZ ".expand("%"))
call setline(8,"#URL: https://blog.51cto.com/13931555")
call setline(9,"#DescriptionZ The test script")
call setline(10,"#Copyright (C): ".strftime("%Y")." All rights reserved")
call setline(11,"#********************************************************************")
call setline(12,"")
endif
endfunc
autocmd BufNewFile * normal G