首页 > 代码库 > 马哥10-5
马哥10-5
while CONDITION ;do
statement
.....
done
进入循环:条件满足
退出循环:条件不满足
until CONDITION;do
STATEMENT
.......
done
进入循环:条件不满足
退出循环:条件满足
#!/bin/bash
#
read -p"Input something:" STRING
while [ $STRING!=‘quit‘ ];do
echo $STRING |tr ‘a-z‘ ‘A-Z‘
read -p "Again,Input something:"STRING
done
#! /bin/bash
#
read -p "Input something:" STRING
until [ $STRING==‘quit‘ ];do
echo $STRING |tr ‘a-z‘ ‘A-Z‘
read -p "Input something:"STRING
done
#! /bin/bash
#
who | grep"hadoop"&> /dev/null
RETVAL=$?
until [ $RETVAL -eq 0 ];do
echo"hadoop is not come!"
sleep 5
who |grep"hadoop" &> /dev/null
RETVAL=$?
done
echo"hadoop is logged in"
for 变量 in 列表;do
循环体
done
for ((expr1;expr2;expr3));do
循环体
done
#!/bin/bash
#
declare -i SUM=0
for I in {1...100};do
let SUM+=$I
done
echo $SUM
declare -i SUM2=0
for((I=1;I<=100;I++));do
let SUM2+=$I
done
echo $SUM2
ping
-c
-w
awk ‘PATTERN{ACTION}‘file
print $1
awk -F ‘{print $1,$3}‘ /etc/passwd
马哥10-5