如何解释 grep 的输出?
How do I interpet output from grep?
我是 运行 grep
Windows 7 通过 Cygwin,我是新手。我只是 运行 它在一个文件上,我得到的唯一输出是我 运行 它所在的文件名。这是否意味着它未能在文件中找到指定的字符串?它给出的输出似乎充其量是空的;最糟糕的是,我无法在任何地方找到这个文档,除了在给定某些选项时它的样子。
如果 grep 找到了正确的字符串,会打印什么?如果没有打印会打印什么?
@哈希姆:
What will be printed if grep has found the right string? What will be
printed if it hasn't?
假设您使用的是简单的 grep
(没有任何正则表达式或任何其他选项),那么当找到搜索字符串的匹配项时将打印它的行,让我们在这里看一个例子。
假设这是我们名为 Input_file.
的文件
cat Input_file
test name etc xyz abc
chumma hero type film
grep "test" Input_file
test name etc xyz abc ---> Output
grep "fill" file445
NO Output as no match found.
此外,如果您使用 grep -l 选项,那么如果在 Input_file 中找到字符串,它将显示 Input_file。
我是 运行 grep
Windows 7 通过 Cygwin,我是新手。我只是 运行 它在一个文件上,我得到的唯一输出是我 运行 它所在的文件名。这是否意味着它未能在文件中找到指定的字符串?它给出的输出似乎充其量是空的;最糟糕的是,我无法在任何地方找到这个文档,除了在给定某些选项时它的样子。
如果 grep 找到了正确的字符串,会打印什么?如果没有打印会打印什么?
@哈希姆:
What will be printed if grep has found the right string? What will be printed if it hasn't?
假设您使用的是简单的 grep
(没有任何正则表达式或任何其他选项),那么当找到搜索字符串的匹配项时将打印它的行,让我们在这里看一个例子。
假设这是我们名为 Input_file.
cat Input_file
test name etc xyz abc
chumma hero type film
grep "test" Input_file
test name etc xyz abc ---> Output
grep "fill" file445
NO Output as no match found.
此外,如果您使用 grep -l 选项,那么如果在 Input_file 中找到字符串,它将显示 Input_file。