Using GREP for special characters

Hi folks

I am issuing the following command:

grep "[\/:*?"<>|#+%&]" *

Looking for the characters \/:*?"<>|#+%& within all files in a directory, but the command fails being unhappy with pipe:

ksh: 0403-057 Syntax error: `|' is not expected.

How do I force the command to take the pipe | ? I guess the same is for *some* of the other symbols.

Regards, Dave

The shell knows 3 kinds of quotes:

  • 'Single Quotes': Use that string as is, no parameter substitution, no globbing, ...
  • "Double Quotes": Use that string as is, after parameter expansion
  • `Backticks`: Use the output of the command between the backticks

So if you change you double to single quotes, it should run fine.

grep "[[:punct:]]"