zoukankan      html  css  js  c++  java
  • linux-shell编程笔记01

    ==============常用命令

    env
    echo $path
    export
    -------------
    cp
    mv
    mkdir
    rm
    -------------
    cd
    ls
    ll
    -------------
    more
    cat
    tail
    vi
    -------------
    ifconfig
    getconf LONG_BIT
    df -h

    ==============shell语法

    #!/bin/bash
    #test1
    echo "Hello shell"
    echo `who`
    echo "who"
    -----------------------
    #!/bin/bash
    #t2
    echo "test 2"
    var1=1
    var2=2
    let var3=$var2+$var1
    echo $var3
    echo "end!"
    -----------------------
    #!/bin/bash
    #t3
    echo "test 3"
    echo "input first integer please:"
    read var1
    echo "input second integer please:"
    read var2
    let var3=var2+var1
    echo $var1+$var2=$var3
    echo "end!"
    -----------------------
    #!/bin/bash
    #t4
    echo "test 4"
    var1=$1
    if [ $var1 -lt 0 ]
    then
    echo "illegal!"
    fi
    echo "end!"
    -----------------------
    #!/bin/bash
    #t5
    echo "test 5"
    var1=$1
    if [ $var1 -lt 0 ]
    then
    echo "illegal!"
    else
    echo "Yeah!"
    fi
    echo "end!"
    
    -----------------------
    #!/bin/bash
    #t6
    echo "test 6"
    var1=$1
    if [ $var1 -lt 0 ]
    then
    echo "illegal!"
    elif [ $var1 -lt 60 ]
    then
    echo "fail!"
    else
    echo "Yeah!"
    fi
    echo "end!"
    
    -----------------------
    #!/bin/bash
    
    sum=0
    for ((i=1;i<101;i++))
    {
        let "sum+=i"
    }
    echo "sum=$sum"
    
    -----------------------
    #!/bin/bash
    
    for animal in cat dog pig duck mice
    do
        echo $animal
    done
    
    -----------------------
    #!/bin/bash
    
    sum=0
    echo "input your number:"
    read num
    
    while(($num>0))
    do
        let "sum+=num"
        let "num--"
    done
    
    echo "sum=$sum"
  • 相关阅读:
    1分钟快速生成用于网页内容提取的xslt
    Python即时网络爬虫项目: 内容提取器的定义
    Python读取PDF内容
    Golang基础(二)
    shell的sed命令
    matplotlib + pandas绘图
    关于字符编码:ascii、unicode与utf-8
    shell的sort命令
    shell的uniq命令
    shell的tr命令
  • 原文地址:https://www.cnblogs.com/SeaSky0606/p/4663776.html
Copyright © 2011-2022 走看看