具有存在文件名的linux grep命令

标签 linux grep

我是 Linux 新手。当我输入 grep filename 并按下 enter 时,它显示了一个带光标的空行,我不得不按下 ctrl+zctrl+c 退出。它不应该向我显示命令不完整的某种错误吗?简而言之,我输入 grep filename 并按下 enter 后发生了什么。

Here is my commands

最佳答案

当您键入 grep test1 时,test1 不是文件名,而是您正在搜索的模式,您的输入文件是 stdin。因此,您的控制台输入将是您的“输入文件”。您可以看到,当您输入包含字符串“test1”的行时,在这种情况下,模式匹配并立即在控制台上再次打印出来。

参见 here对于它的手册页

grep searches the named input FILEs (or standard input if no files are named, or if a single hyphen-minus (-) is given as file name)

关于具有存在文件名的linux grep命令,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38288303/

相关文章:

windows - svn 工作副本的快速递归 grepping

linux - grep 正则表达式

linux - 如何从内核空间读取路由表信息?

python - paramiko 中的管道命令

arrays - 如何精确地将 "grep"与点 "."对齐?

selenium - 检查当前 chromedriver 的位置

c - 如何监控linux自旋锁等待时间?

linux - 在 x86 汇编语言中获取文件大小的简单方法

C++查找USB设备挂载点

linux - 如何将 git 命令的输出存储在变量中?