1 bash ksh shell-script shebang source-command
我#!/bin/ksh
在第一行有脚本。当我尝试执行此脚本 (run ./myscript.sh
) 时发生错误:
-bash: ./myscript.sh: /bin/ksh: bad interpreter: No such file or directory
Run Code Online (Sandbox Code Playgroud)
但是当我通过source myscript.sh
或bash myscript.sh
命令执行此脚本时- 脚本成功运行。
是的,没有安装ksh,安装这个是正确的。但我无法理解不同的行为./
和bash
或source
小智 5
当使用./
来自 shebang 行的解释器执行脚本时,将调用。
使用source
当前的 shell(source
是一个 bash 扩展,所以你必须运行 bash)
使用bash script.sh
shellscript 调用 PATH 中的 bash shell。
归档时间: |
|
查看次数: |
11667 次 |
最近记录: |