Zeophlite
Zeophlite

Reputation: 1617

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

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?

Upvotes: 8

Views: 9235

Answers (2)

harpo
harpo

Reputation: 43198

Just escape the dots:

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

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

Upvotes: 17

Daniel Wolfe
Daniel Wolfe

Reputation: 662

Escape the dots with backslashes: \.

Upvotes: 1

Related Questions