Newsgroups: comp.unix.questions Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!think.com!snorkelwacker.mit.edu!thunder.mcrcim.mcgill.edu!mouse From: mouse@thunder.mcrcim.mcgill.edu (der Mouse) Subject: Re: How do I search for apostrophe using egrep? Message-ID: <1991Jul1.005840.11611@thunder.mcrcim.mcgill.edu> Organization: McGill Research Centre for Intelligent Machines References: <1991Jun25.074801.517@weyrich.UUCP> Distribution: usa Date: Mon, 1 Jul 91 00:58:40 GMT Lines: 27 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