Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Grepping for '../' (dot dot slash)

Tags:

regex

grep

I'm trying to search my directory for files that contain ../ with grep -r -n '../' *, but I get lots of false positives. grep is interpreting the period as a wild character, how do I stop this?

like image 252
Zeophlite Avatar asked Oct 12 '11 03:10

Zeophlite


2 Answers

Just escape the dots:

grep -r -n '\.\./' *

Tested in Cygwin. Dot is of course a wildcard in regular expressions.

like image 120
harpo Avatar answered Oct 22 '22 11:10

harpo


Escape the dots with backslashes: \.

like image 26
Daniel Wolfe Avatar answered Oct 22 '22 10:10

Daniel Wolfe