zoukankan      html  css  js  c++  java
  • bash example

    for x in one two three four
    do
        echo number $x
    done


    for myfile in /etc/r*
    do
        if [ -d "$myfile" ]
        then
          echo "$myfile (dir)"
        else
          echo "$myfile"
        fi
    done


    for x in /etc/r??? /var/lo* /home/drobbins/mystuff/* /tmp/${MYPATH}/*
    do
        cp $x /mnt/mydir
    done


    while [ condition ]
    do
        statements
    done

    myvar=0
    until [ $myvar -eq 10 ]
    do
        echo $myvar
        myvar=$(( $myvar + 1 ))
    done

    case "${x##*.}" in
         gz)
               gzunpack ${SROOT}/${x}
               ;;
         bz2)
               bz2unpack ${SROOT}/${x}
               ;;
         *)
               echo "Archive format not recognized."
               exit
               ;;
    esac   


    Functions


    tarview() {
        echo -n "Displaying contents of $1 "
        if [ ${1##*.} = tar ]
        then
            echo "(uncompressed tar)"
            tar tvf $1
        elif [ ${1##*.} = gz ]
        then
            echo "(gzip-compressed tar)"
            tar tzvf $1
        elif [ ${1##*.} = bz2 ]
        then
            echo "(bzip2-compressed tar)"
            cat $1 | bzip2 -d | tar tvf -
        fi
    }


    myvar="hello"

    myfunc() {
        local x
        local myvar="one two three"
        for x in $myvar
        do
            echo $x
        done
    }

    myfunc

    echo $myvar $x

  • 相关阅读:
    读取Web.config文件中的配置信息类
    屏蔽页面中的右键操作
    树型目录
    自己常用的分页SQL
    c#用一个线程同步的简单例子

    c++面向对象学习
    数据上传项目总结
    简单的xml学习
    c#中跨线程使用控件
  • 原文地址:https://www.cnblogs.com/greencolor/p/2072579.html
Copyright © 2011-2022 走看看