Shell 文件包含
来源:互联网 发布:录音整理文字软件 mac 编辑:程序博客网 时间:2024/04/29 13:28
Shell 文件包含
和其他语言一样,Shell 也可以包含外部脚本。这样可以很方便的封装一些公用的代码作为一个独立的文件。
Shell 文件包含的语法格式如下:
. filename # 注意点号(.)和文件名中间有一空格或source filename
实例
创建两个 shell 脚本文件。
test1.sh 代码如下:
#!/bin/bash# author:W3Cschool教程# url:www.w3cschool.cnurl="http://www.w3cschool.cn"
test2.sh 代码如下:
#!/bin/bash# author:W3Cschool教程# url:www.w3cschool.cn#使用 . 号来引用test1.sh 文件. ./test1.sh# 或者使用以下包含文件代码# source ./test1.shecho "W3Cschool教程官网地址:$url"
接下来,我们为 test2.sh 添加可执行权限并执行:
$ chmod +x test2.sh $ ./test2.sh W3Cschool教程官网地址:http://www.w3cschool.cn
注:被包含的文件 test1.sh 不需要可执行权限。
0 0
- linux shell 包含文件
- shell 文件包含
- shell 包含文件
- Shell文件包含
- Shell文件包含
- Shell文件包含
- shell文件包含
- Shell 文件包含
- Shell文件包含
- Shell文件包含
- shell 文件包含
- Shell 文件包含
- Shell 文件包含
- Shell 文件包含
- Shell 文件包含
- Shell 文件包含
- Shell文件包含~12
- shell 文件包含
- MySQL 存储过程或者函数中传参数实现where id in(1,2,3,...)IN条件拼接
- zookeeper集群搭建
- Linux学习
- Spring注解之 @PostConstruct和 @PreDestroy
- textField详解
- Shell 文件包含
- Hadoop面试
- NodeJS 常用模块推荐
- 详细的KVO总结,包括基本改变,使用案例,注意点.看我就够了!
- 算法导论学习笔记(一)
- Stanford机器学习-Matrices and vectors
- 高性能MySQL读书笔记
- android-获取手机信号强度(2)
- 业务应用