Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Grep Tab, Carriage Return, & New Line

Tags:

grep

I'm trying to use Grep to find a string with Tabs, Carriage Returns, & New Lines. Any other method would be helpful also.

grep -R "\x0A\x0D\x09<p><b>Site Info</b></p>\x0A\x0D\x09<blockquote>\x0A\x0D\x09\x09<p>\x0A\x0D\x09</blockquote>\x0A\x0D</blockquote>\x0A\x0D<blockquote>\x0A\x0D\x09<p><b>More Site Info</b></p>" *
like image 781
user3851589 Avatar asked Oct 31 '25 14:10

user3851589


1 Answers

From this answer

If using GNU grep, you can use the Perl-style regexp:

$ grep -P '\t' *

Also from here

Use Ctrl+V, Ctrl+M to enter a literal Carriage Return character into your grep string. So:

grep -IUr --color "^M"

will work - if the ^M there is a literal CR that you input as I suggested.

If you want the list of files, you want to add the -l option as well.

like image 176
SriniV Avatar answered Nov 04 '25 05:11

SriniV



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!