【发布时间】:2021-07-10 19:48:42
【问题描述】:
这会正确打印test
$ echo 'this is a test' | awk '{print $4}'
test
在/bin/bash -c 中使用此命令不起作用
/bin/bash -c "echo 'this is a test' | awk '{print $4}'"
this is a test
与/bin/bash -c 一起使用时,如何让awk 正常工作?
【问题讨论】:
-
是的:
/bin/bash -c "echo 'this is a test' | awk '{print \$4}'" -
注意:您需要转义
$。生病搜索重复;) -
@anubhava Phh,某种阅读障碍? 'this' !== 'test'....谢谢你的叫醒服务。
-
另外,dupe 只谈论
bash -c,但 OP 也在询问awk,并且该 dupe 没有解释为什么 OP 的输出是完整的。