Bash scripts: Sequential execution in process-oriented programming: Default rules, execute each statement by execution: branching, conditional judgment, execution of the eligible branches; loop execution: The same piece of code is executed repeatedly for a limited number of times, so the loop must have an exit condition or it will fall into a dead loop ; Program code: Statements and expressions constitute control statements: Bash loop control statement: Forwhileuntilfor loop:for var_name in list; do Statement 1 Statement 2...donefor userName in gentoo mandriva debian; douseradd $userNamedone syntax error detection:# bash -n script File Write a script: Add 10 Users, user101-user110 list generation method: Generate a sequence of numbers: {start. End}, seq [start] [step] end#!/bin/bashfor username in ' seq 101 110 '; do useradd user$userName echo "add user$username successfully." Done write a script: delete user102 user105 users #!/bin/bash for username in user102 user105; do userdel $userName echo "del $userName successfully." done
This article is from the "-it commune" blog, please be sure to keep this source http://guangpu.blog.51cto.com/3002132/1547909
Bash scripts Add, remove Linux users