Leslie E. Ballentine wrote:
> >[EMAIL PROTECTED] ~]% cat testfile
> >12345
> > -o sss
> >-o
> >
> >[EMAIL PROTECTED] ~]% grep 'o' testfile
> > -o sss
> >-o
> >[EMAIL PROTECTED] ~]% grep '-o' testfile
>
> At this point, grep hangs indefinitely.
> It seems that grep cannot find the string '-o'.

It is waiting for input, because it interprets '-o' as the 
option -o, and thus sees testfile as a pattern.

> And how do I search a file for the characters "-o"?

Precede it with the option -e.

$ grep -e -o testfile

Or quote plus escape the dash:

$ grep '\-o' testfile

Just quoting the pattern is not enough, because anything can be 
quoted, for example:

$ 'grep' '-e' 'hmm' '-e' '-o' 'testfile'

Benno


Reply via email to