如何使用GREP匹配但不打印比赛?
我是Linux Shell的新手,并且正在尝试使用以下条件进行此操作,最好是在一行中:它无法向终端输出任何内容。
/var/folder/program.exe -L parameters | grep text_to_filter && echo SomeText >'/tmp/Log.txt'
问题是.exe将XML数据吐出到终端。我无法弄清楚如何进行grep,使用退出状态,但没有对每场比赛的输出的屏幕混乱。如果我使用/dev/null 2>& 1
,它将其管道非常好,但是我无法掌握数据。有什么想法吗?
I'm new to linux shell and am trying to do this, preferably in one line, with the following condition: It can't output anything to the terminal.
/var/folder/program.exe -L parameters | grep text_to_filter && echo SomeText >'/tmp/Log.txt'
The problem is the .exe spits out XML data to terminal. I can't figure out how to grep, use the exit status, but not have the screen cluttered with the output of each match. If I use /dev/null 2>&1
, it pipes it quite but then I can't grep the data. Any idea's?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
使用
GREP -Q
(QUIET)按照
man grep
:Use
grep -q
(quiet)As per
man grep
:尝试使用|&而不是只是|。 (需要bash 4)
Try using |& rather than just |. (needs bash 4)