On 17Jul2007 11:26, Indika Bandara <[EMAIL PROTECTED]> wrote: | file: | ---------------------- | xyz foob abc | abc foobar | ---------------------- | how to get output as | ---------------------- | foob | foobar | ---------------------- | | e.g i can remove this pattern by | sed -e 's/foob*//' | | so, it should be possible to remove the negated pattern too... isn't it
Yeah, depending on exactly what you mean. Your incantation removes from the first "foob" onwards. This: s/.*\(foob.*\)/\1/ will remove up to the LAST "foob" because regexps are greedy - the ".*" will match as much as possible while still letting the rest of the regexp also match. So "---foob1---foob2---" will give "---foob1---" to the leading ".*" and "foob2---" to the "foob.*". This: s/foob.*/\n&/ s/^.*\n// will remove up to the FIRST "foob". -- Cameron Simpson <[EMAIL PROTECTED]> DoD#743 http://www.cskk.ezoshosting.com/cs/ I am reminded of a memorable scene in "Falling Down", starring Michael Douglas. In fact, I'm reminded of the whole damn movie, from glorious start to amusing finish. I nominate it as the official movie of alt.peeves. - mathew, [EMAIL PROTECTED] To unsubscribe from this list, please email [EMAIL PROTECTED] & you will be removed. Yahoo! Groups Links <*> To visit your group on the web, go to: http://groups.yahoo.com/group/LINUX_Newbies/ <*> Your email settings: Individual Email | Traditional <*> To change settings online go to: http://groups.yahoo.com/group/LINUX_Newbies/join (Yahoo! ID required) <*> To change settings via email: mailto:[EMAIL PROTECTED] mailto:[EMAIL PROTECTED] <*> To unsubscribe from this group, send an email to: [EMAIL PROTECTED] <*> Your use of Yahoo! Groups is subject to: http://docs.yahoo.com/info/terms/
