Shell中调用/引用/包含另外的脚本文件的两种方法,也可以使用sh fi


脚本 first (测试示例1)

1

#!/bin/bash

2

echo'your are in first file'

问)在当前脚本文件中调用另外一个脚本文件?

方法一: 使用source

脚本 second (测试示例2)

1

#!/bin/bash

2

echo'your are in second file'

3

sourcefirst

方法二: 使用.

脚本 second (测试示例3)

1

#!/bin/bash

2

echo'your are in second file'

3

. first

source filename和 . filename 应该是同一回事,都是在*当前*Shell环境中执行脚本。也可以使用sh filename,那是在当前Shell的子Shell中执行脚本。

相关内容

    暂无相关文章