[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: grep '-o' ???

From: Benno Schulenberg
Subject: Re: grep '-o' ???
Date: Thu, 01 Nov 2007 11:51:04 +0100
User-agent: KMail/1.9.7

Leslie E. Ballentine wrote:
> >address@hidden ~]% cat testfile
> >12345
> > -o sss
> >-o
> >
> >address@hidden ~]% grep 'o' testfile
> > -o sss
> >-o
> >address@hidden ~]% 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'


reply via email to

[Prev in Thread] Current Thread [Next in Thread]