开发者

How do I grep for a backtick?

开发者 https://www.devze.com 2023-03-22 02:11 出处:网络
So I\'m trying to find backticks (`) in files, so I ran: grep -irl \'\\`\' ./* 开发者_运维知识库This seems to return every single file possible...

So I'm trying to find backticks (`) in files, so I ran:

grep -irl '\`' ./*
开发者_运维知识库

This seems to return every single file possible...

What else can I try?


My apologies everyone, you have to use -I to ignore binary files. Those were the files that were being returned. I didn't realize this until I removed -l, which indicated to me that the results were binary in nature.

grep -rlI '`' ./*

From the man page:

   -I     Process a binary file as if it did not contain  matching  data;
          this is equivalent to the --binary-files=without-match option.


If you don't actually need to match the backtick itself, but you are looking to match something enclosed by a backtick ( like auto-generated MySQL table names, for instance) a single-character wildcard (".") also does the trick.

I'm using it like this today:

grep "INSERT INTO .my_table." sqldump.sql


just go with, it worked for me

grep -ri \` *


grep -irl '`' *

or

grep -irl \\` *
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号