https://www.bilibili.com/video/BV1dW411M7xL?p=58
    A = 100 定义A = 100
    echo “A=$A” A=100
    unset A 取消变量
    echo “A=$A” A=

    readonly A =99 定义静态变量 A =100
    echo “A=$A” A=99
    unset A 静态变量不能被unset
    echo “A=$A” A=99
    image.png
    image.png
    ls -l /home “ ` “是反引号 ESC下面那个按键

    shell脚本注释
    单行注释
    #

    多行注释
    :<<!
    A = 100
    echo “A=$A”
    !

    export 变量名=变量值 将shell变量输出为环境变量

    位置参数变量
    image.png
    image.png
    上面的shell脚本执行结果 :
    image.png
    预定义变量
    image.png
    $((运算式)) $[运算式]
    expr 运算符间要有空格 写 \ 转译
    image.png
    条件判断
    image.png
    [ ] 条件判断式 左右必须有空格,=左右必须没有空格
    image.png
    if语句
    if[ -r 文件 ]
    then 程序
    elif [ 条件判断式 ]
    then 程序
    fi

    case 语句
    case 变量值 in
    “1”)
    程序
    ;;
    “2”)
    程序
    ;;
    *)
    程序
    ;;
    esac

    for循环
    image.png
    image.png
    image.png
    while 与[] 之间一定要用空格

    read读取控制台输入
    image.png
    系统函数
    basename
    image.png
    dirname
    image.png
    自定义函数
    image.png
    shell自定义函数不用定义形参 ,调用函数时也不用加括号

    Shell综合案例
    image.png
    image.png
    crontab -e
    image.png