• shell的环境变量


    1./etc/profile 

    用户登录时,自动读取/ect目录下profile文件,此文件包括

    • 全局或局部环境变量
    • PATH信息
    • 终端设置
    • 安全命令
    • 日期信息或放弃操作信息

    2.stty用法

    stty用于设置终端特性。要查询现在的stty选项,使用stty -a

    $stty -a

    stty的一个选项为-g,此选项允许以只读格式保存stty现有设置,便于以后重置回stty.

    3.显示变量

    使用echo命令可以显示单个变量,并在变量名前加$,例如:

    $ DOLLAR=99

    $ echo ${DOLLAR}

    99

    $ LAST_FILE=s2

    $ echo ${LAST_FILE}

    s2

    $ ERROR="This is user: $LOGNAME"

    $ echo ${ERROR}
    This is user: dongjichao

    4.清除变量

    使用unset命令清除变量

    $ PC=enterprise

    $ echo ${PC}

    enterprise

    $ unset PC

    $ echo ${PC}

    $

    5.显示所有本地shell变量

    $ set | more

    6.测试变量是否已经设置

    $ echo "The file is ${FILES:?}"

    FILES: parameter null or not set

    7.显示环境变量

    $ CONSOLE=tty1;  export CONSOLE

    $ echo $CONSOLE

    tty1

    使用env命令可以查看所有的环境变量

    $ env

    8.使用export导出变量

    有一父进程

    $ cat father.sh
    #!/bin/sh
    echo "this is the father"
    FILM="A Few Good Men"
    echo "I like the file :$FILM"
    #call the child script
    export FILM    #去掉此句,在child.sh中变量$FILM则为空
    child.sh
    echo "back to father"
    echo "and the file is :$FILM"

    子进程为
    $ cat child.sh
    #!/bin/sh
    echo "called from father.. i am the child"
    echo "film name is :$FILM"
    FILM="Die Hard"
    echo "changing file to :$FILM"

    运行father输出:

    $ father.sh
    this is the father
    I like the file :A Few Good Men
    called from father.. i am the child
    film name is :A Few Good Men
    changing file to :Die Hard
    back to father
    and the file is :A Few Good Men

  • 相关阅读:
    第四周:卷积神经网络 part3
    第四周作业:卷积神经网络学习part3
    视频学习--《 图像语义分割前沿进展》
    视频学习--《语义分割中的自注意力机制和低秩重建》
    第二次作业:卷积神经网络 part 1
    使用VGG模型迁移学习进行猫狗大战
    使用 VGG16 对 CIFAR10 分类
    CIFAR10 数据集分类
    MNIST数据集分类
    第一次作业:深度学习基础
  • 原文地址:https://www.cnblogs.com/djcsch2001/p/2046107.html
Copyright © 2020-2023  润新知