Shell 文件包含
来源:互联网 发布:java 递归删除子节点 编辑:程序博客网 时间:2024/04/29 15:30
Shell 文件包含
和其他语言一样,Shell也可以包含外部脚本。这样可以很方便的封装一些公用的代码作为一个独立的文件。
Shell 文件包含的语法格式如下:
. filename #注意点号(.)和文件名中间有一空格
或
source filename
实例
创建两个 shell脚本文件。
test1.sh代码如下:
#!/bin/bash
# author:菜鸟教程
#url:www.runoob.com
url="http://www.runoob.com"
test2.sh代码如下:
#!/bin/bash
# author:菜鸟教程
#url:www.runoob.com
#使用 .号来引用test1.sh文件
../test1.sh
# 或者使用以下包含文件代码
# source./test1.sh
echo "菜鸟教程官网地址:$url"
接下来,我们为 test2.sh添加可执行权限并执行:
$ chmod +x test2.sh
$ ./test2.sh
菜鸟教程官网地址:http://www.runoob.com
注:被包含的文件 test1.sh不需要可执行权限。
阅读全文
0 0
- linux shell 包含文件
- shell 文件包含
- shell 包含文件
- Shell文件包含
- Shell文件包含
- Shell文件包含
- shell文件包含
- Shell 文件包含
- Shell文件包含
- Shell文件包含
- shell 文件包含
- Shell 文件包含
- Shell 文件包含
- Shell 文件包含
- Shell 文件包含
- Shell 文件包含
- Shell文件包含~12
- shell 文件包含
- leetcode 十一周解题报告
- 克隆创建PDB--(3)远程克隆NON-CDB创建PDB
- AngularJS
- 《Web接口开发与自动化测试基于Python语言》--第7章
- nginx配置文件讲解
- Shell 文件包含
- 18、结果集映射的简单使用
- leetcode第十七周解题总结
- 手机移动端web前端常见问题整理
- 当一个程序员写不出代码了,该怎么办?
- 19、结果集映射之多对一关联映射
- centos7.x 配置(php7.x) + mariadb + apache
- 线性探测法的查找函数
- Leetcode513. Find Bottom Left Tree Value