[SATLUG] sed and Regular expression question

Bruce Dubbs bruce.dubbs at gmail.com
Thu Mar 14 14:47:12 CDT 2013

Frank Huddleston wrote:
> Greetings,
>     I'd like to know how to use sed to replace part of a matched string
> but leave part of it as it was before. That is, if sed can even do this.
> Here's my example: I've got a lot of music files: the Diabelli
> Variations by Beethoven. Each one has something like
> "Variation_29GAllegro-moderato" in it. I'd like to put a dash after that
> "G", but just replacing "G" with "G-"
> is error-prone and just sloppy.

Why?  Are there a lot of G's? With 's/G/G-/', the regular expression 
will only change the first G instance by default.

   -- Bruce

More information about the SATLUG mailing list