“#!/bin/sh"的用途/含义是什么?在 shell 脚本中?

编程入门 行业动态 更新时间:2024-10-26 11:24:23
本文介绍了“#!/bin/sh"的用途/含义是什么?在 shell 脚本中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时送ChatGPT账号..

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/LDP/abs/html/sha-bang.html#MAGNUMREF

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

更多推荐

[db:关键词]

本文发布于:2023-04-28 17:07:50,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1176894.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:脚本   含义   用途   sh   bin

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!