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...
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"
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?