Iii. settings for Bash script parameters

Source: Internet
Author: User

Settings for Bash script parameters


Select parameter Add|del Add Delete user1-user10



#! /bin/bash


If [$#-lt 1];then

echo "Usage:adminusers ARG"

Exit 5

Fi

if [= = '--add '];then

For I in {1..10};d o

If ID user$i &>/dev/null;then

echo "user$i exists."

Else

Useradd-r user$i

echo user$i |passwd--stdin user$i &>/dev/null

echo "ADD Uesr$i finished."

Fi

Done

elif [= = '--del '];then

For I in {1..10};d o

if! ID user$i &>/dev/null;then

echo "No user$i."

Else

Userdel user$i

echo "Del User$i finished."

Fi

Done

Else

echo "Unknown ARG"

Exit 6

Fi


This article is from the "Shell Learning One" blog, please be sure to keep this source http://zhangdefa.blog.51cto.com/11498478/1774921

Iii. settings for Bash script parameters

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.