本文介绍了如何在bash shell脚本中包含文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否有一种方法可以在外壳程序脚本中包含另一个外壳程序脚本,以便能够访问其功能?
Is there a way to include another shell script in a shell script to be able to access its functions?
就像在PHP中可以如何将include指令与其他PHP文件一起使用,以便仅通过调用函数名来运行包含在其中的函数.
Like how in PHP you can use the include directive with other PHP files in order to run the functions that are contained within simply by calling the function name.
推荐答案只需将其放入脚本中即可:
Simply put inside your script :
source FILE或
. FILE是同一回事.
$ LANG=C help source source: source filename [arguments] Execute commands from a file in the current shell. Read and execute commands from FILENAME in the current shell. The entries in $PATH are used to find the directory containing FILENAME. If any ARGUMENTS are supplied, they become the positional parameters when FILENAME is executed. Exit Status: Returns the status of the last command executed in FILENAME; fails if FILENAME cannot be read.更多推荐
如何在bash shell脚本中包含文件
发布评论