gacvd 发表于 2018-8-28 07:46:51

笔记整理之 SHELL 变量

# url1=test.3glong.com         #定义自定义变量  
# export url2=test2.3glong.com#定义环境变量
  
# /bin/bash             #再开启一个bash进入子shell
  
# pstree
  
init─┬─abrtd
  
   ├─acpid
  
   ├─anacron
  
   ├─atd
  
   ├─auditd───{auditd}
  
   ├─console-kit-dae───63*[{console-kit-da}]
  
   ├─crond
  
   ├─cupsd
  
   ├─dbus-daemon
  
   ├─dhclient
  
   ├─hald─┬─hald-runner─┬─hald-addon-acpi
  
   │      │             └─hald-addon-inpu
  
   │      └─{hald}
  
   ├─login───bash
  
   ├─master─┬─pickup
  
   │      └─qmgr
  
   ├─5*
  
   ├─rpc.statd
  
   ├─rpcbind
  
   ├─rsyslogd───3*[{rsyslogd}]
  
   ├─sshd───sshd───bash───bash───pstree   #确认处于子shell
  
   ├─udevd───udevd
  
   └─xinetd
  
# echo $url1         #输出自定义变量
  
                                                                #发现什么都没有
  
# echo $url2
  
test2.3glong.com                                 #环境变量输出了
  
# exit                        #退出当前子shell
  
exit
  
# echo $url1
  
test.3glong.com                                     #自定义变量只能当前shell使用
  
# echo $url2
  
test2.3glong.com
  
# export url1               #转换i自定义变量为环境变量
  
# /bin/bash
  
# echo $url1               #进入子shell
  
test.3glong.com                                       #子shell也正常了


页: [1]
查看完整版本: 笔记整理之 SHELL 变量