“#!/bin/sh"的用途/含义是什么?在 shell 脚本中? [英] What is the use/meaning of "#!/bin/sh" in shell scripting?

查看:39
本文介绍了“#!/bin/sh"的用途/含义是什么?在 shell 脚本中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

shell 脚本中#!/bin/sh"的用途/含义是什么?请让我知道它是否在脚本中被考虑,因为它被评论.

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.

推荐答案

脚本开头的 sha-bang (#!) [1] 告诉您的系统该文件是一组要提供给指示的命令解释器的命令.这 #!实际上是一个两字节 [2] 的幻数,一个指定文件类型的特殊标记,或者在这种情况下是一个可执行的 shell 脚本(输入 man magic 以获得有关这个迷人主题的更多详细信息).紧跟在 sha-bang 后面的是路径名.这是解释脚本中命令的程序的路径,无论它是 shell、编程语言还是实用程序.这个命令解释器然后执行脚本中的命令,从顶部(sha-bang 行之后的行)开始,并忽略注释.[3]

The sha-bang ( #!) [1] at the head of a script tells your system that this file is a set of commands to be fed to the command interpreter indicated. The #! is actually a two-byte [2] magic number, a special marker that designates a file type, or in this case an executable shell script (type man magic for more details on this fascinating topic). Immediately following the sha-bang is a path name. This is the path to the program that interprets the commands in the script, whether it be a shell, a programming language, or a utility. This command interpreter then executes the commands in the script, starting at the top (the line following the sha-bang line), and ignoring comments. [3]

来源:http://tldp.org/LDP/abs/html/sha-bang.html#MAGNUMREF

这篇关于“#!/bin/sh"的用途/含义是什么?在 shell 脚本中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆