shell - -f 在解释器定义中是什么意思 : ! #/bin/awk -f

标签 shell unix awk interpreter shebang

-f 在解释器定义中是什么意思:#!/bin/awk -f 它是一个 awk 脚本

最佳答案

awk-f 命令行选项指定下一个参数应该是要从中读取命令的文件。

如果您省略 -f,解释器将尝试使用 /bin/awk yourScriptFile 调用您的脚本,这将失败,例如:

$ cat yourScriptFile 
#!/bin/awk
{ print $1; }
$ ./yourScriptFile 
awk: cmd. line:1: ./yourScriptFile
awk: cmd. line:1: ^ syntax error
awk: cmd. line:1: ./yourScriptFile
awk: cmd. line:1:   ^ unterminated regexp

有关详细信息,请参阅 awk ( http://pubs.opengroup.org/onlinepubs/009695399/utilities/awk.html) 或 man 1 awk 的 POSIX 文档。

关于shell - -f 在解释器定义中是什么意思 : ! #/bin/awk -f,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37294680/

相关文章:

shell - 使用 Expect 将文件从一个远程复制到另一个

linux - 参数没有传递好

c++ - 错误 : implicit declaration of function `int open(...)'

shell - 如何在 Shell 脚本中捕获 exit 1 信号?

mysql - 重启后如何让 Shell 脚本继续运行?

linux - 读取 shell 脚本中的行输出

shell - 如何获取错误输出并将其存储在变量或文件中

bash - 在 awk 中重置行号计数

awk - 使用awk查找KB中的数字然后更改并替换为GB并显示整行

shell - BASH : Find number in text -> variable