【问题标题】:Grep : find patterns in text fileGrep : 在文本文件中查找模式
【发布时间】:2012-07-24 07:54:30
【问题描述】:

我必须在文本文件中找到以下模式

\xc2d 
d\xa0 
\xe7 
\xc3\ufffdd 
\xc3\ufffdd 
\xc2\xa0 
\xc3\xa7 
\xa0\xa0 

我首先查找\x 的出现并执行此操作

 grep "\\x" *.log | more  

没有任何返回,这个查询是否正确?

【问题讨论】:

  • 要么您的文件内容与您向我们展示的内容不同,要么文件未以 .log 结尾。我对包含这些确切行的文件运行了相同的查询,然后我得到了所有的行(我应该有)。

标签: linux grep


【解决方案1】:

我认为你会想要使用单引号而不是双引号。

grep '\\x' *.log | more

你的shell可能是stripping that first backslash as part of the processing it does for strings in double quotes,这是grep需要的。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-02-21
    • 1970-01-01
    • 2017-09-09
    • 2011-08-07
    • 1970-01-01
    • 2016-10-07
    • 2017-02-18
    • 2012-03-06
    相关资源
    最近更新 更多