On Mon, 16 Jul 2007, Michael O'Keefe wrote:
> Gus Wirth wrote:
> > I have a bunch of lines similar to the following generated from an rpm spec
> > file using grep:
> >
> > %{_libdir}/wine/odbc32.dll.so
> >
> > I want to trim off the front part %{_libdir}/wine/ and the back part .dll.so
> > leaving only the base name of the file. All the lines have exactly the same
> > front and back parts so I can do an exact match. I'm trying to figure out if
> > I can do the removal in one shot or if I need two passes to do this, but
> > right now about the only thing I know about sed is that it exists and is
> > used for stuff like this. Trying to use GNU info pages is a recipe for
> > headaches. Is there a simple reference for sed anywhere other than the
> > O'Reilly sed & awk book? Or, since this is a one-off project, can someone
> > give me some hints?
>
> s/^.*\/\(.*\)\.dll\.so$/\1/
> GNU sed version 4.1.5
To add to what Michael said, with gnu sed you can also do something
like:
sed 's!^.*/\(.*\)\.dll\.so$!\1!'
sed will automagically pick up on the first character after the 's'
and use that as your delimiter. It doesn't buy you much here, but it
can save you some \/ when working with long pathnames and the like.
-Deke
--
[email protected]
http://www.kernel-panic.org/cgi-bin/mailman/listinfo/kplug-list