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

  • 相关阅读:
    Centos常用命令(四、进程)
    搭建git服务器(Centos7)
    tortoiseGit使用
    docker常用命令
    配置docker阿里云加速器_CentOS7
    Centos常用命令(三、网络配置)
    Centos常用命令(二、任务调度和磁盘管理)
    spring的作用
    什么是spring框架
    get和post的区别
  • 原文地址:https://www.cnblogs.com/greencolor/p/2072579.html
Copyright © 2011-2022 走看看