zoukankan      html  css  js  c++  java
  • 变量

    一、变量分类

    1. 本地变量:用户私有变量,只有本用户可以使用,保存在家目录的.bash_profile、.bashrc文件中
    2. 全局变量:所有用户都可以使用,保存在/etc/profile、/etc/bashrc文件中
    3. 用户自定义变量:用户自定义,比如脚本中的变量
    

    备注:全局变量在系统开机时会把bash_profile和bashrc读入到内存中,本地变量会在用户登陆成功之后加载这个两个文件都内存
    本地变量和全局变量存在周期是开机到关机,脚本中自定义变量存在时间是脚本执行完毕,临时变量存在时间是当前终端关闭

    二、定义管理

    1. 取消变量:unset
        在/etc/profile、/etc/bashrc、.bash_profile、.bashrc中写入新变量,如果不重启,想要立即生效可以执行source+修改的文件路径  
    2. 定义全局变量:export 变量名=""
        export关键字只是临时生效,重启之后就清除了,想要永久保存需要把export 变量名=""写入到文件中/etc/profile、/etc/bashrc
    
    When nothing seems to help, I go look at a stonecutter hammering away at his rock, perhaps a hundred times without as much as a crack showing in it. Yet at the hundred and first blow it will split in two, and I know it was not that blow that did it, but all that had gone before. -- Jacob Riis
  • 相关阅读:
    hdu 1754 I Hate It
    hdu 2546 饭卡
    hdu 4506 小明系列故事——师兄帮帮忙
    hdu 3665 Seaside
    hdu 3790 最短路径问题
    hdu 1869 六度分离
    最长递增字串的三种做法
    问题集???
    IOS开发学习 碎片S
    超级台阶 (NYOJ—76)
  • 原文地址:https://www.cnblogs.com/xhwy-1234/p/12114729.html
Copyright © 2011-2022 走看看