shell script while loop

Article Directory

while loop

Repeat test a certain condition, as long as the condition is established, the loop will be repeated, and the condition will be exited from the loop (the opposite of the until loop)

 while 条件测试操作
do
    命令序列
done

Insert picture description here
Insert picture description here
Insert picture description here

while loop title

Add users in batches. The
user name starts with stu and is numbered in sequence. A
total of 20 users are added, that is, stu1, stu2, stu3...stu20, and the
initial passwords are all set to 123456. Number
Insert picture description here
Insert picture description here
Insert picture description here
guessing game
Get random integers between 0 and 999 through the variable RANDOM to
prompt users to guess , And record the number of times. If the
guessed number is too large or small, the user will be prompted. If the guess is successful, exit the loop.
Insert picture description here
Insert picture description here
Calculate the sum of all integers from 1 to 100 and
Insert picture description here
Insert picture description here
filter out the odd and even numbers of all integers from 1 to 100.
Insert picture description here
Insert picture description here
Prompt the user to enter an integer less than 100 and calculate The sum of all integers from 1 to this number
Insert picture description here
Insert picture description here
Find the even and odd numbers of all integers from 1 to 100, and
Insert picture description here
Insert picture description here
detect whether the host in the specified range is communicating, and output the communication host ip to the file host_ip.
Insert picture description here
Insert picture description here
Output all available in the /dev directory executable file

Execute the script to enter the user name, if the user exists, the output prompts that the user already exists; if the user does not exist, prompt the user to enter the password, create the user and set up its password

Guess you like

Origin blog.csdn.net/MQ107/article/details/114575553
Recommended