[comp.unix.questions] How do I search for apostrophe using egrep?

orville@weyrich.UUCP (Orville R. Weyrich) (06/25/91)

I have been trying to make egrep search for words which are enclosed in
apostrophes, for example 'hello'.

I can't seem to get this to work. 

Will some kind soul tell me how to do this?

I am running Microport System V/386 rev 3.

Thanks.

Orville.



--------------------------------------           ******************************
Orville R. Weyrich, Jr., Ph.D.                   Certified Systems Professional
Internet: orville%weyrich@uunet.uu.net             Weyrich Computer Consulting
Voice:    (602) 391-0821                         POB 5782, Scottsdale, AZ 85261
Fax:      (602) 391-0023                              (Yes! I'm available)
--------------------------------------           ******************************

dkeisen@leland.Stanford.EDU (Dave Eisen) (06/25/91)

In article <1991Jun25.074801.517@weyrich.UUCP> orville@weyrich.UUCP (Orville R. Weyrich) writes:
>I have been trying to make egrep search for words which are enclosed in
>apostrophes, for example 'hello'.
>

egrep "'hello'" filename or

egrep \'hello\' filename

jrw@mtune.att.com (Jim Webb) (06/26/91)

In article <1991Jun25.074801.517@weyrich.UUCP> orville@weyrich.UUCP (Orville R. Weyrich) writes:
>I have been trying to make egrep search for words which are enclosed in
>apostrophes, for example 'hello'.
>
>I can't seem to get this to work. 

		egrep "'.*'" filename

works for me on SVR3.

---Jim

mouse@thunder.mcrcim.mcgill.edu (der Mouse) (07/01/91)

In article <1991Jun25.074801.517@weyrich.UUCP>, orville@weyrich.UUCP (Orville R. Weyrich) writes:

> I have been trying to make egrep search for words which are enclosed
> in apostrophes, for example 'hello'.

> I can't seem to get this to work.

	egrep \''[^'\'']*'\'

or perhaps less confusingly,

	egrep "'[^']*'"

where I am assuming you want to require that the word itself not
contain any 's.

Your problem is unlikely to be with egrep; more likely it's shell
quoting conventions tripping you up.  Decide what regex you want to
pass to egrep, then play with echo until you get the quoting right so
that your regex gets through intact.  If egrep doesn't like it *then*,
you may have problems.

					der Mouse

			old: mcgill-vision!mouse
			new: mouse@larry.mcrcim.mcgill.edu