bash - 命令'source'有什么作用?
问题描述
我想知道这个命令source
是做什么的。我努力了:
- 什么是
$ whatis source
source: nothing appropriate.
- 男人
$ man source
No manual entry for source
- 来源(-h、--help 等...)
$ source
source: not enough arguments
但似乎没有关于它的文档。
我通常使用它来保存对我的点文件的任何更改,但它到底有什么作用?为什么没有关于它的文档?
解决方案
source
是一个 bash shell 内置命令,它在当前 shell中执行作为参数传递的文件的内容。.
它在(句号)中有同义词。
句法
. filename [arguments] source filename [arguments]
从源手册
source filename [arguments]
Read and execute commands from filename in the current shell environment and
return the exit status of the last command executed from filename. If
filename does not contain a slash, file names in PATH are used to find the
directory containing filename. The file searched for in PATH need not be
executable. When bash is not in posix mode, the current directory is
searched if no file is found in PATH. If the sourcepath option to the short
builtin command is turned off, the PATH is not searched. If any arguments
are supplied, they become the positional parameters when filename is
executed. Otherwise the positional parameters are unchanged. The return
status is the status of the last command exited within the script (0 if no
commands are executed), and false if filename is not found or cannot be
read.
当心!./
和source
不太一样。
./script
将脚本作为可执行文件运行,启动一个新的 shell来运行它source script
从当前 shell环境中的 filename 读取并执行命令
注意:./script
不是. script
,而是. script
==source script
推荐阅读
- java - 在抽象类的具体类中自动装配而不是实现接口
- sails.js - addToCollection 并设置中间表列值
- xml - TSQL xml unicode 内联分配失败
- maven - 在 mvnrepository.com 上反映 Maven 坐标的变化
- php - mysql join查询如何使用php访问两个表数据
- javascript - 如何在浏览器中使用后退和前进按钮浏览页面而不丢失 NextJS 中的页面状态?
- javascript - 垂直排序父母,水平排序孩子
- php - 一页有两个分页 YII2
- amp-html - 我们可以在 amp 故事网格层标签中使用 amp youtube 标签吗
- python - 从导入的 XML 文件访问列表索引