0

How do you use grep to find occurrences of strings in a directory, when the string to search for is '../images/'? This is the command as I normally use it

grep -H -r 'string to find' /path/to/dir

Some search characters cause problems, and evidently '../' is among those.

I tried various combinatrions of \ in front of some characters This is a search I need to do frequently, to find references in css files that are pointing to images in the folder next door.

Avinash Raj
  • 172,303
  • 28
  • 230
  • 274
DanAllen
  • 352
  • 1
  • 4
  • 15
  • You could also use `fgrep`, if available on your platform, which does not treat "." as special characters. – bufh Jul 31 '15 at 04:54

1 Answers1

3

The dot matches any character with grep. You need to prefix it with a backslash, e.g '\.\./images/'

Patrick Maupin
  • 8,024
  • 2
  • 23
  • 42