码迷,mamicode.com
首页 > 其他好文 > 详细

马哥10-5

时间:2014-12-02 12:01:19      阅读:119      评论:0      收藏:0      [点我收藏+]

标签:something

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

标签:something

原文地址:http://9154368.blog.51cto.com/9144368/1585313

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!