日积月累:Linux中的点命令(.)和source命令
来源:互联网 发布:快手喊麦都用什么软件 编辑:程序博客网 时间:2024/05/16 05:29
. filename [arguments]
source filename [arguments]
在当前shell环境中,读取并执行filename中的命令,返回最后一条命令的exit值。
在BASH中,点(.)和source命令都是BASH的内置命令,C-shells只支持source命令。
source或点(.)命令的用途:
重新执行初始化文件,如 .bash_profile 和 .profile等。.bash_profile和.bashrc无需可执行权限。
当需要改变当前shell的多个环境变量时,执行设置环境变量的脚本文件。这也是一种共享环境变量的方法。
示例:
http://www.linuxidc.com/Linux/2012-10/72744.htm
source filename [arguments]
在当前shell环境中,读取并执行filename中的命令,返回最后一条命令的exit值。
在BASH中,点(.)和source命令都是BASH的内置命令,C-shells只支持source命令。
source或点(.)命令的用途:
重新执行初始化文件,如 .bash_profile 和 .profile等。.bash_profile和.bashrc无需可执行权限。
当需要改变当前shell的多个环境变量时,执行设置环境变量的脚本文件。这也是一种共享环境变量的方法。
示例:
[azureuser@vmname02 ~]$ ls -lrt...-rw-rw-r--. 1 azureuser azureuser 22 Oct 6 10:50 test.bash# 不必有执行权限-rw-rw-r--. 1 azureuser azureuser 26 Oct 6 11:10 test.tcsh# 不必有执行权限-rwxrwxr-x. 1 azureuser azureuser 27 Oct 6 11:22 test.sh# 需要执行权限,才能在shell命令行上执行[azureuser@vmname02 ~]$ cat test.sh# test.sh的内容echo $var[azureuser@vmname02 ~]$ cat test.bash# test.bash的内容var="hello"echo $var[azureuser@vmname02 ~]$ cat test.tcsh# test.tcsh的内容set var = helloecho $var[azureuser@vmname02 ~]$ var=hello# 在当前shell中,定义var变量[azureuser@vmname02 ~]$ echo $varhello[azureuser@vmname02 ~]$ ./test.sh# 产生一个新shell来执行脚本,变量var未定义[azureuser@vmname02 ~]$ [azureuser@vmname02 ~]$ export var=hello# export的变量只对当前shell和它的子shell有效[azureuser@vmname02 ~]$ ./test.shhello[azureuser@vmname02 ~]$ source test.bash# BASH支持source命令hello[azureuser@vmname02 ~]$ echo $var# var变量在当前shell中有效hello[azureuser@vmname02 ~]$ var= # 重置变量[azureuser@vmname02 ~]$ echo $var[azureuser@vmname02 ~]$ . test.bash# BASH支持 . 命令hello[azureuser@vmname02 ~]$ echo $var# var变量在当前shell中有效hello[azureuser@vmname02 ~]$ /bin/tcsh -x# -x 执行前回显命令[azureuser@vmname02 ~]$ . test.tcsh# C-shells 不支持 . 命令. test.tcsh/usr/bin/.: Permission denied.[azureuser@vmname02 ~]$ source test.tcsh# C-shells 支持source命令source test.tcshset var = helloecho hellohello[azureuser@vmname02 ~]$ echo $var# var变量在当前shell中有效echo hellohello
参考:
http://linuxmanpages.com/man1/source.1.phphttp://www.linuxidc.com/Linux/2012-10/72744.htm
0 0
- 日积月累:Linux中的点命令(.)和source命令
- linux点命令和source命令
- linux source 点命令
- 日积月累--linux命令
- Linux命令日积月累
- linux中的source命令
- linux 中的source命令
- Linux中的source命令
- shell中的点命令与source命令
- shell中的点命令与source命令
- shell中的点命令与source命令
- linux下source命令(点命令)
- linux source( . )命令
- Linux基础—source、点(.)和sh命令执行脚本的方式解析
- linux source和export命令
- shell 点命令和source指令
- linux中的source命令和直接执行脚本的区别
- Linux命令 source命令
- 在网页中添加视频(HTML)
- log4j日志配置文件
- UNIX高级环境2的环境搭建
- git 理解Git的工作流程
- DOCTYPE的影响
- 日积月累:Linux中的点命令(.)和source命令
- RTSP server 在mips 上莫名其妙退出(PC上则无此问题)
- poj 2001字典树
- StrictMode函数
- 虚拟机创建教程
- mutable的用法
- html的结构详解
- Fibonacci 数
- acdream 1227 Beloved Sons 二分匹配