Bar*_*jeu 8 bash shell-script shebang
我有一个来自其他人的脚本,可以查看(注意:它是一个文件):
#!/bin/bash
some commands
some commands
#!/bin/bash
some commands
some commands
#!/bin/bash
some commands
some commands
Run Code Online (Sandbox Code Playgroud)
我想知道第二次和第三次shebangs的目的是什么?是误会还是故意的?
dan*_*dan 10
如果这些行不是要构建的包含的 shell 脚本的开头,即在以下形式的方案中:
cat <<end_of_shell_script >dynamically_built_shell
#!/bin/bash
[...]
end_of_shell_script
Run Code Online (Sandbox Code Playgroud)
然后,你发现了重复的结构是很多人的结果copy
-paste
全shell脚本,但没有足够的照顾和什么是对脚本的第1行中使用这些非常特殊的评论的理解,开始#!
。
在使用这样的 shell 脚本之前要小心(不sudo
,不su
:))。