从grep手册来看,grep使用的一般形式是:
grep options pattern input_file_names特别是,“可以有零或多个输入文件名”。
如果文件名为零,那么搜索的候选文件是什么?例如。grep mystr
发布于 2014-11-18 21:08:00
来自man grep:
file A pathname of a file to be searched for the patterns. If no file
operands are specified, the standard input shall be used.因此,如果没有管道或重定向,它将等待您键入一些文本。
发布于 2014-11-18 21:10:50
如果没有指定任何文件名,则从标准输入(文件描述符0)中读取。
grep foo相当于:
grep foo -允许这样的事情:
grep foo < file或者:
cmd | grep foo如果grep foo是在终端中的交互式shell提示下运行的,那么grep将从终端设备读取,因此从您通过键盘输入的内容中读取。
https://unix.stackexchange.com/questions/168734
复制相似问题