"<<<&#34 ;?的目的是什么?

时间:2018-02-15 22:20:02

标签: shell

我想申请an answer about non interactive postfix installation on debian distros。但我没有理解其中<<<运算符的含义,这是我第一次看到它:

debconf-set-selections <<< "postfix postfix/mailname string your.hostname.com"

它的目的是什么?

当我尝试时,我收到/bin/sh: 1: Syntax error: redirection unexpected错误。

1 个答案:

答案 0 :(得分:1)

它是 here-string ,并非所有shell都使用此语法,但至少

检查:

echo 'string' | command

  

此处文件的变体,格式为:

     

[N]&LT;&LT;      

这个词经历括号扩展,波浪扩展,参数和变量扩展,命令替换,算术扩展,   和报价删除。不执行路径名扩展和单词拆分。结果作为单个字符串提供,带有   新标志附加到其标准输入上的命令(如果指定了n,则为文件描述符n。)

它就像 here-doc 但是我们只有一个字符串而不是行

您的错误意味着您使用的是posix shell ,并且不支持 here-string

要解决此问题,请使用或使用 pipe ,如下所示:

{{1}}