[SATLUG] sed and Regular expression question
bruce.dubbs at gmail.com
Sat Mar 16 19:35:01 CDT 2013
Frank Huddleston wrote:
> sed can use up to 9 back references. \(foobar\) \1
> sed -e 's/Variation_\([0-9]*\)G/Variation_\1G-/g'
> Thanks, Don: that's exactly what I wanted: "back references".
> As to why I didn't just search and replace for "G": yes, that's what I
> did, and it worked: this time. But I figured I might as well find out
> how to do it with the back references: it could come in handy.
You might want to look at the -r switch too. You don't need to escape
as many characters.
sed -r -e 's/(Variation_[0-9]*)G/\1G-/'
I wouldn't think you wanted the suffix /g in this case. Did you want to
More information about the SATLUG