什么是#!(砰磅)在sh /的Bash shell脚本的含义是什么? [英] What is the meaning of !# (bang-pound) in a sh / Bash shell script?
问题描述
我想了解这个斯卡拉脚本是如何工作的:
I want to understand how this Scala script works:
#!/usr/bin/env bash
exec scala "$0" "$@"
!#
object HelloWorld {
def main(args: Array[String]) {
println("Hello, world! " + args.toList)
}
}
HelloWorld main args
在3号线,什么是#!在干什么?是该文件的剩余部分,然后输送到标准输入斯卡拉方案?还有,就是'!#记录任何地方?
On line 3, what is "!#" doing? Is the remainder of the file then fed to standard input of the Scala program? Also, is '!#' documented anywhere?
注:我能找到最近的事情,虽然这是不以任何方式直接相关的是堆栈溢出问题的 为什么需要把#!/斌/庆典在脚本文件的开始? 的(约猛砸脚本)。
NB: The nearest thing I could find, although it is not directly relevant in any way is Stack Overflow question Why do you need to put #!/bin/bash at the beginning of a script file? (about the beginning of a Bash script).
推荐答案
从的原始文档:
脚本文件可能需要如果present被忽略的一个可选的头。有两种方法来格式化标题:要么以#开始!和!#结尾,或::#开始!与::#!结束。
Script files may have an optional header that is ignored if present. There are two ways to format the header: either beginning with #! and ending with !#, or beginning with ::#! and ending with ::!#.
所以下面code是只是一个斯卡拉脚本头:
So the following code is just a header for a Scala script:
#!/usr/bin/env bash
exec scala "$0" "$@"
!#
这篇关于什么是#!(砰磅)在sh /的Bash shell脚本的含义是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!