I want to use grep command to search for files containing the string "/usr/vm/data". For searching a normal string like "how are you", i know i can do:
grep -inr "how are you" *
to search recursively. But i am getting stuck in the cases where i need to search a path like "/usr/vm/data". I tried: grep -inr "\/usr\/vm\/data" directory1
and also grep -inr "/usr/vm/data/" directory1 but didn't get any success.
2 Answers
Don't torture yourself, and it is a normal string (especially when you put it in quotes).
echo "/usr/vm/data Hello world" | grep -i "/usr/vm/data" 0Your command works fine:
$ cat directory1/somefile foo bar this line contains /usr/vm/data/ $ grep -inr "/usr/vm/data/" directory1 directory1/somefile:3:this line contains /usr/vm/data/ $ Perhaps your file is beyond a symlink which grep doesn't follow, or perhaps you don't have any matching files?