Demand:
Bulk delete users using the For loop
[Email protected] ~]# Cat/etc/passwdroot:x:0:0:root:/root:/bin/bash. stu01:x:1001:1001::/home/stu01:/bin/bashstu02:x:1002:1002::/home/stu02:/bin/bashstu03:x:1003:1003::/home/stu03 :/bin/bashstu04:x:1004:1004::/home/stu04:/bin/bashstu05:x:1005:1005::/home/stu05:/bin/bashstu06:x:1006:1006::/ Home/stu06:/bin/bashstu07:x:1007:1007::/home/stu07:/bin/bashstu08:x:1008:1008::/home/stu08:/bin/bashstu09:x : 1009:1009::/home/stu09:/bin/bashstu10:x:1010:1010::/home/stu10:/bin/bash
Delete Stu01-stu10 in bulk
Script content:
#!/bin/bash #mp for i in '/usr/bin/echo stu{01..10} ' does userdel-r $i done
Execution process:
[[email protected] ~]# sh-x userdel.sh +/usr/bin/echo stu01 stu02 stu03 stu04 stu05 stu06 stu07 stu08 stu09 stu10+ for I in '/usr/bin/echo stu{01..10} ' "+ userdel-r stu01userdel:user ' stu01 ' does not exist+ for I in '/usr/bin/echo stu{01. . Ten} ' + userdel-r stu02userdel:user ' stu02 ' does not exist
Use for loop to delete the specified user at this point
Shell Learning-delete users in bulk