Title: Add 20 users in bulk, username user1~20, password is 5 random characters (requires no Shell loop statement)
Workaround
Method 1
Echo User{1..20}|xargs-n1|sed-r ' s# (. *) #useradd \1 \&\& echo \1 >>/tmp/passwd.txt \&\& Echo $RANDO M |md5sum |cut-c 1-5>>/tmp/passwd.txt \&\& echo ' tail-1/tmp/passwd.txt ' |passwd--stdin \1#g ' |bash
Method 2
Echo User{1..20}|xargs-n1|sed-r ' s# (. *) #useradd \1 \&\& pass= ' echo $RANDOM |md5sum |cut-c 1-5 ' \&\& ech o $pass |passwd--stdin \1 \&\& echo \1 $pass >>/tmp/user_passwd.txt#g ' |bash
Method 3
Echo User{1..20}|xargs-n1|sed-r ' s# (. *) #useradd \1 \&\& pass= ' echo $RANDOM |md5sum |cut-c 1-5 ' \&\& ech o \ 1: $pass >>/tmp/user_passwd.txt \&\& chpasswd</tmp/user_passwd.txt#g ' |bash
Note
Today is the day to accompany everyone's __ 63rd Day __, look forward to your progress.
for questions and answers, please leave a comment in the blog comments section. Previous issue index http://lidao.blog.51cto.com/3388056/1914205
This article is from the "Lee blog" blog, make sure to keep this source http://lidao.blog.51cto.com/3388056/1936495
Old boy Education daily-63rd day-Batch create user and set random password (requires no Shell loop statement)