如何让grep 从标准输入(stdin)读取表达式?
例如(以下不起作用):
grep -i -f &0 /path/to/text/file < "/regexp/"
Run Code Online (Sandbox Code Playgroud)
thk*_*ala 42
使用-f单个破折号表示标准输入:
$ echo Content | grep -f - notice.html
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
...
Run Code Online (Sandbox Code Playgroud)
注意:这已经使用GNU grep进行了测试 - 我不确定它是否由POSIX指定.