Title Requirements: Through Shell programming, to achieve bulk add users.
Save As any file name: Give x permission
Add user1.user2.user3....user10, Password = user name without any arguments
Plus parameter example: COMMAND-A Test 20 command-A add test is the user's first 20 is to add quantity (add up to no more than 100, the following code can be modified)
command-d test Deletes the user name in the system that begins with test, followed by a number, and without test, the USER1.USER2.USER3 is deleted by default ... This type of user ... Be careful with ...
#!/bin/bash U=${2:-user} num=${3:-10} res= ' Grep-o ' ^\< $U [0-9]\{1,\}\> '/etc/passwd|grep-o ' [0-9]\{1,\} ' |sort-n |tail-1 ' res1=${res:-0} res2=$ ((res1+num)) all= ' cat/etc/passwd|wc-l ' if [[Z $ | | | ' && = = $ &
& $3-le]];then for ((i=${res1};i<=${res2};i++)) do if [[$i-ne 0]];then Useradd ${u} $i &>/dev/null echo "${u} $i" |passwd--stdin ${u} $i && Gt /dev/null fi done aall= ' cat/etc/passwd|wc-l ' echo ' ADD user num
BER is $ ((aall-all)) "Elif [[!-Z $ && '] = ' d ']]; then for ((i=${res1};i>=1;i--) do res3= ' grep-o ' ^\<${u}${i}\> '/etc/passwd ' if [[-N $Res 3 && ' ${u} $i ' = ' $
Res3 "]];then userdel-r ${u} $i &>/dev/null fi done Dall= ' Cat/etc/passWd|wc-l ' echo ' Del user number is $ ((all-dall)) "Else Echo-e" \033[33;5merror!\033[0m please INP UT none or-a or-d "fi