shell 編程 (7)文件包含

在一個sh腳本中執行另一個sh腳本

使用:

. ./t0.sh

source ./t0.sh

中間有一空格

eg:

[root@k8s-master test3]# ll
總用量 8
-rw-r--r--. 1 root root 28 3月  21 01:15 t0.sh
-rw-r--r--. 1 root root 60 3月  21 01:16 t2.sh
[root@k8s-master test3]# sh t2.sh 
Hello world
[root@k8s-master test3]# cat t0.sh 
#!/bin/bash

hello="Hello"

[root@k8s-master test3]# cat t2.sh 
#!/bin/bash

. ./t0.sh
# source ./t0.sh
echo "$hello world"
[root@k8s-master test3]# 

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章