#!/bin/bash# This shell script will create amount of Linux login accounts for you.# 1. check the "accountadd.txt" file exist? you mush create that file manually.# one account name one line in the "accountadd.txt" file.# 2. use openssl to create users password.# 3. user must change his password in his first login.# 4. more option.# 2023/11/26 chen pengexportPATH# 0. userinputpwmech="openssl"# 1. check the accountadd.txt fileif[!-f accountadd.txt ];thenecho-e"There is no accountadd.txt file, stop here."exit1firm-f outputpw.txt # clear outputpw.txt to place new account's passwordusernames=$(cat accountadd.txt)forusernamein$usernamesdouseradd-m-s /bin/bash ${username}# new username (default create home directory and use /bin/bash)if["$pwmech"=="openssl"];thenusepw=$(openssl rand -base646)# it will output a random string that's 8 characters long#else# usepw=$usernamefiecho"$username:$usepw"| chpasswd # new passwordchage -d0$username# force password changeecho"username=$username, password=$usepw">> outputpw.txt
done
go tree
代码实现请看 gitee 仓库链接
有很多生成目录树的工具,比如windows自带的tree命令,nodejs的treer,tree-cli等等。这些工具都很成熟、很好用,有较完善的功能。
但是,这些工具全部是命令式的,如果…