Linux命令最好截图 用Shell脚本完成批量用户的生成 要求: 数量 ,100人 帐号,AAAA,AAAB。。。。。。AAB

2025-01-01 22:06:03
推荐回答(1个)
回答1:

[root@flycat scripts]# more s02.sh
#!/bin/bash
for ((i=1;i<=5;i++));
do
useradd AA"$i"
done
[root@student01 scripts]# bash -x ./s02.sh
+ j=0
+ (( i=1 ))
+ (( i<=5 ))
+ useradd AA1
+ (( i++ ))
+ (( i<=5 ))
+ useradd AA2
+ (( i++ ))
+ (( i<=5 ))
+ useradd AA3
+ (( i++ ))
+ (( i<=5 ))
+ useradd AA4
+ (( i++ ))
+ (( i<=5 ))
+ useradd AA5
+ (( i++ ))
+ (( i<=5 ))
[root@flycat scripts]# tail -5 /etc/passwd
AA1:x:512:512::/home/AA1:/bin/bash
AA2:x:513:513::/home/AA2:/bin/bash
AA3:x:514:514::/home/AA3:/bin/bash
AA4:x:515:515::/home/AA4:/bin/bash
AA5:x:516:516::/home/AA5:/bin/bash