我想知道命令
f = open("blah.txt", "a")
subprocess.call(["python","loop.py"], stdout=f,stderr=f)
的作用。我尝试过:
source
$ whatis source
source: nothing appropriate.
$ man source
No manual entry for source
但是似乎没有关于它的文档。
我通常使用它来保存我的点文件中的所有更改,但是它究竟能做什么?为什么没有关于它的文档?
答案 0 :(得分:1)
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 环境中从文件名读取并执行命令注意:./script
不是. script
,而是. script
== source script