在BashVersion4.2.47(1)-release中,当我尝试对来自这里的文本的格式化文本进行链接时,如下所示:
cat <(fmt --width=10 <<FOOBAR
(I want the surrounding parentheses to be part of the HERE-document)
(Even the preceding unbalanced parenthesis should be part of it.
FOOBAR
) # I want this paranthesis to end the process substitution.我得到以下错误:
bash: bad substitution: no closing `)' in <(fmt --width=10 <<FOOBAR
(I want the surrounding parentheses to be part of the HERE-document)
(Even the preceding unbalanced parenthesis should be part of it.
FOOBAR
)另外,我不想引用这里的文档,即写<'FOOBAR',因为我仍然希望在其中替换变量。
发布于 2015-10-31 12:02:34
这是一个老问题,当您意识到这是一个人为的例子(因此正确的解决方案是使用cat |,或者在本例中实际上根本不使用cat )时,我将只发布我对一般情况的答案。我会把它放在一个函数中,然后用它来解决它。
fmt-func() {
fmt --width=10 <<FOOBAR
(I want the surrounding parentheses to be part of the HERE-document)
(Even the preceding unbalanced parenthesis should be part of it.
FOOBAR
}然后用它
cat <(fmt-func)发布于 2014-06-17 00:55:48
这只是一个解决办法。将fmt输送到cat,而不是使用进程替换
fmt --width=10 <<FOOBAR | cat
(I want the surrounding parentheses to be part of the HERE-document)
(Even the preceding unbalanced parenthesis should be part of it.
FOOBARhttps://unix.stackexchange.com/questions/137506
复制相似问题