展开
拓展 关闭
订阅号推广码
GitHub
视频
公告栏 关闭

shell文件包含

  • 案例
# 新建脚本
[root@VM-12-15-centos home]# vi test1.sh
# 编写如下
username="goudan"

# 新建脚本
[root@VM-12-15-centos home]# vi test2.sh
# 编写如下
#使用 . 号来引用test1.sh 文件
. ./test1.sh
#或者使用以下包含文件代码
#source ./test1.sh
echo "用户名是:$username"

# 设置权限
[root@VM-12-15-centos home]# chmod +x test2.sh
# 执行
[root@VM-12-15-centos home]# ./test2.sh
用户名是:goudan
posted @ 2024-05-15 11:16  DogLeftover  阅读(3)  评论(0编辑  收藏  举报