从标准输入读取grep的表达式 [英] Read expression for grep from standard input
本文介绍了从标准输入读取grep的表达式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何让grep从标准输入(stdin)中读取表达式?
例如(以下操作不起作用) : grep -i -f& 0 / path / to / text / file< / regexp /
解决方案使用
-f
用一个短划线表示标准输入: $ echo内容| grep -f - notice.html
< meta http-equiv =Content-Typecontent =text / html; charset = ISO-8859-1>
...
注意:这已经过GNU grep测试 - 我不确定如果它是由POSIX指定的话。
How can I make grep read the expression from standard input (stdin)?
For example (the following doesn't work):
grep -i -f &0 /path/to/text/file < "/regexp/"
解决方案
Use -f
with a single dash to denote the standard input:
$ echo Content | grep -f - notice.html
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
...
Note: This has been tested with GNU grep - I am not sure if it's specified by POSIX.
这篇关于从标准输入读取grep的表达式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文