On Fri, 04 Jun 2004 17:30:28 +0200, Ralph Crongeyer <[EMAIL PROTECTED]> wrote:
> Carlos Hanson wrote: > > >On Fri, 04 Jun 2004 10:31:07 -0400 > >Ralph Crongeyer <[EMAIL PROTECTED]> wrote: > > > >>I need to do a pattern match with sed of "(" and ")". I need to replace > >>every ( with "(" and every ) with ")" on every line. > > > >sed 's/[()]/"&"/g' > > > Carlos, Thanks! > By the way, what does the & mean? Substitute the previously found string. So in this case, sed will search (letter 's') for either a ( or a ) (character class [()]) and replace it with a double quote, the previously found open or close bracket and another double quote. My advice: do some reading on regular expressions. For me, the book 'mastering regular expressions' by O'Reilly was really helpful. There's SO much that you can do more effectively with regular expressions and sed... Last week, I had to extract a few lines of useful information from an 850MB logfile. My favorite editor (NEdit) had some memory problems and refused to open it, but a small awk-program and a lot of regular expressions with sed and grep got the job done in a matter of minutes. -- Matthijs [EMAIL PROTECTED] -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]