如何在bash shell脚本中包含文件

编程入门 行业动态 更新时间:2024-10-27 02:18:55
本文介绍了如何在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脚本中包含文件

本文发布于:2023-10-09 10:26:58,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1475486.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:脚本   文件   如何在   shell   bash

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!