[SATLUG] sed and Regular expression question
dondavis at reglue.org
Thu Mar 14 14:28:55 CDT 2013
sed can use up to 9 back references. \(foobar\) \1
sed -e 's/Variation_\([0-9]*\)G/Variation_\1G-/g'
On Thu, Mar 14, 2013 at 2:20 PM, Frank Huddleston <fhuddles at gmail.com> wrote:
> 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. So I think my regular expression match would
> be something like /Variation_[0-9]+G/.
> Feel free to jump in and correct that.
> But whatever it is: how do I "save" and put that number in the replacement
> Yes, I know that Perl and Awk can do this. I just want to know: can sed do
> it, and if so, how?
> Thanks for any help you can provide.
> Frank Huddleston
> SATLUG mailing list
> SATLUG at satlug.org
> http://alamo.satlug.org/mailman/listinfo/satlug to manage/unsubscribe
> Powered by Rackspace (www.rackspace.com)
More information about the SATLUG