How do i use grep command to find a text that includes a string like /usr/vm/data/?

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" 
0

Your 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?

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like