How do you grep for a string containing a slash?

LookIntoEast picture LookIntoEast · Jun 27, 2012 · Viewed 45.5k times · Source

How should I grep for a string containing a forward slash like ./.?

Answer

Todd A. Jacobs picture Todd A. Jacobs · Jun 27, 2012

The forward slash is not a special character in grep, but may be in tools like sed, Ruby, or Perl. You probably want to escape your literal periods, though, and it does no harm to escape the slash. This should work in all cases:

\.\/\.