zoukankan      html  css  js  c++  java
  • shell for的用法

    #!/bin/sh

    for1(){

    for i in 1 2 3 4 5 6
    do
    echo "$i"
    done

    }


    for1
    #!/bin/sh
    for2(){
    for i in {1..10}
    do
    echo "$i"

    done


    }

    for2
    #!/bin/sh

    for3(){

    sum=0
    #int=1

    for i in {1..100..2}
    do
    let "sum+=i"
    done

    echo "sum is $sum"
    }

    for3
    #!/bin/sh

    for4(){
    sum=0

    for i in $(seq 1 2 100)
    do
    let "sum+=i"
    done

    echo "sum is $sum"
    }

    for4
    #!/bin/sh

    for5(){

    for file in $(ls)

    do
    echo "file: $file"
    done
    }

    for44(){

    for file1 in $( ls )

    do
    echo "file: $file1"
    done


    }


    #for5
    echo "*****************"
    for44
    #!/bin/sh

    echo "the number of arguments is $#"

    for i in "$*"
    do
    echo "$i"
    done
    #!/bin/sh
    for8(){
    sum=0
    for ((int=1;int<200;int++))
    do
    let "sum+=int"

    done

    echo "the sum is $sum"

    }


    for8
    #!/bin/sh

    for9(){
    sum=1


    for (( i=9;i>0;i-- ))
    do
    echo "$i"
    let "sum*=i"
    done

    echo "the sum is $sum"

    }

    for9

  • 相关阅读:
    Python安装appium 遇见的报错
    appium
    QQ邮箱/微信邮箱发送邮件
    Python-变量
    神秘的咒语
    宿命的PSS
    E. Congruence Equation
    D. Substring
    leetcode 761. Special Binary String
    F
  • 原文地址:https://www.cnblogs.com/luo-mao/p/5941387.html
Copyright © 2011-2022 走看看