问题描述
我以前做脚本和他们都没有这个运行良好的开头。是什么把它在的地步?将事情有什么不同?
I have made Bash scripts before and they all ran fine without this at the beginning. What's the point of putting it in? Would things be any different?
此外,你怎么念#
?我知道,!
发音为砰。
Also, how do you pronounce #
? I know that !
is pronounced as "bang."
如何#!
发音?
推荐答案
这是一个约定,以便在* nix的外壳知道什么样的跨preTER的运行。
It's a convention so the *nix shell knows what kind of interpreter to run.
例如,AT&T的较旧的口味默认为SH(Bourne shell的),而旧版本的BSD的默认设置为CSH(C外壳程序)。
For example, older flavors of ATT defaulted to "sh" (the Bourne shell), while older versions of BSD defaulted to "csh" (the C shell).
即使在今天(大部分系统上运行的庆典中,伯恩再次壳牌),脚本可以在bash中,蟒蛇,Perl中,红宝石,PHP,等等,等等。例如,您可能会看到!/ bin中/ perl的或/斌/ perl5的。
Even today (where most systems run "bash", the "Bourne Again Shell"), scripts can be in bash, python, perl, ruby, PHP, etc, etc. For example, you might see "!/bin/perl" or "/bin/perl5".
PS:
感叹号(!),被亲切地称为砰的一声。外壳注释符号(#)有时被称为哈希。
PS:The exclamation mark ("!") is affectionately called "bang". The shell comment symbol ("#") is sometimes called "hash".
PPS:
记住 - 在* nix中,后缀与文件类型关联仅仅是一个的约定的,不是一个规则。 可执行可以是一个二进制程序,一百万脚本类型和其他东西,以及任何一种。因此,需要#!/斌/ bash的。
PPS:Remember - under *nix, associating a suffix with a file type is merely a convention, not a "rule". An "executable" can be a binary program, any one of a million script types and other things as well. Hence the need for "#!/bin/bash".
这篇关于为什么你需要把#!/斌/庆典在脚本文件的开头?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!