我对Bash脚本很陌生。我偶然发现了这链接,并注意到猫的一个不寻常的语法。
cat << !
HOPE THIS WORKS
This sample E-mail message demonstrates how one can attach
files when sending messages with the Unix sendmail utility.
!
uuencode ${file_1} ${file_1}
uuencode ${file_2} ${file_2}
uuencode ${file_3} ${file_3}
!<<是什么意思?这是什么!卑劣?为什么猫有一个开口和关闭!,但uuencode没有?
编辑:,谢谢你的帮助!最后一个悬而未决的问题是,为什么uuencode部分没有打开和标记。据我所知,cat有一个<< !表示它是一个HEREDOC。然而,uuencode看起来并不像一个HEREDOC。怎么回事?
发布于 2016-05-04 23:19:55
它被称作为本文档,其构造方式如下:
command << MARKER
Literal text here, can contain $variables
and newlines,
leading spaces
and tabs...
MARKER并与MARKER之间的所有内容一起工作,与指定命令的stdin一样。您使用的标记是可选的,在您的示例中使用的是!。如果在stdin上输入命令cat,它只需将其打印到stdout:
cat << !
all this text will go to stdout
!https://stackoverflow.com/questions/37037812
复制相似问题