java文件版本管理包_SHELL脚本编程和文件软件包管理工具

1、编写脚本 createuser.sh,实现如下功能:使用一个用户名做为参数,如果 指定参数的用户存在,就显示其存在,否则添加之;显示添加的用户的id号等信息

[root@centos8 data]# vim createuser.sh

#!/bin/bash

#

#*****************************************************

#Author: lqf

#QQ: 393833084

#Date: 2021-01-09

#FileName: createuser.sh

#URL: http://www.magedu.com

#Description: The test script

#Copyright(c): 2021 All rights reserved

#******************************************************

set -ue

NAME=$1

id $NAME &> /dev/null && echo "$NAME is exist" || { useradd "$NAME";echo "$NAME is created";echo "id $NAME";id "$NAME"; }

[root@centos8 data]# chmod +x createuser.sh

[root@centos8 data]# ./createuser.sh lqf

lqf is exist

[root@centos8 data]# ./createuser.sh test

test is created

id test

uid=1001(test) gid=1001(test) groups=1001(test)

2、编写生成脚本基本格式的脚本,包括作者,联系方式,版本,时间,描述等

[root@centos8 ~]# vim .vimrc

set ignorecase

set cursorline

set autoindent

autocmd BufNewFile *.sh exec ":cal SetTitle()"

func SetTitle()

if expand("%:e")=='sh'

call setline(1,"#!/bin/bash")

call setline(2,"#")

call setline(3,"#*****************************************************")

call setline(4,"#Author: lqf")

call setline(5,"#QQ: 393833084")

call setline(6,"#Date: ".strftime("%Y-%m-%d"))

call setline(7,"#FileName: ".expand("%"))

call setline(8,"#URL: http://www.magedu.com")

call setline(9,"#Description: The test script")

call setline(10,"#Copyright(c): ".strftime("%Y")." All rights reserved")

call setline(11,"#******************************************************")

call setline(12,"")

endif

endfunc

脚本格式结果如下图

895cb9ab4dce1bab6d4d3d8d28256756.png

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值