What is the use/meaning of "#!/bin/sh
" in shell scripting? Please let me know whether it is considered in the script or not as it is commented.
相关问题
- How to get the return code of a shell script in lu
- Invoking Mirth Connect CLI with Powershell script
- Why should we check WIFEXITED after wait in order
- Emacs shell: save commit message
- “command not found” errors in expect script execut
相关文章
- 使用2台跳板机的情况下如何使用scp传文件
- In IntelliJ IDEA, how can I create a key binding t
- shell中反引号 `` 赋值变量问题
- How get the time in milliseconds in FreeBSD?
- Making new files automatically executable?
- Reverse four length of letters with sed in unix
- Launch interactive SSH bash session from PHP
- Generate disk usage graphs/charts with CLI only to
It is the path where the shell executable file is located.
A script may specify #!/bin/bash on the first line, meaning that the script should always be run with bash, rather than another shell. /bin/sh is an executable representing the system shell. Actually, it is usually implemented as a symbolic link pointing to the executable for whichever shell is the system shell
It is used by the OS for regular files which have the execution bit set. If the file is not recognized as a "pure" binary format (ie, ELF, or DWARF, or other), the OS tries and reads
#!/path/to/interpreter -plus -options
and transforms:into:
It also arranges for argc and argv to be correct (ie, argv[0] will be your script name, and argv[1] being option 1 etc).
This also works for perl scripts, python scripts and whatnot. In fact, for whatever interpreter of your choice.
it means your script will run in compatibility-mode (POSIX) when executed directly (even if
/bin/sh
is an alias to bash)citations for the downvoters:
http://en.wikipedia.org/wiki//bin/sh
and:
http://en.wikipedia.org/wiki/Bash_(Unix_shell)#Portability
Source: http://tldp.org/LDP/abs/html/sha-bang.html#MAGNUMREF