The UNIX and Linux Forums
>
Top Forums
>
Shell Programming and Scripting
Back Referencing in SED
.
User Name
Remember Me?
Password
google unix.com
Forums
Register
Forum Rules
Links
Albums
FAQ
Members List
Calendar
Search
Today's Posts
Mark Forums Read
Thread
:
Back Referencing in SED
View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
#
2
(
permalink
)
01-02-2009
Christoph Spohr
Registered User
Join Date: Sep 2008
Posts: 205
Hi,
Code:
sed
's/a\(..\)a/\1/' <<< "abba"
output:
Code:
bb
The backreference \1 saves the two characters betweens the as.
Everything between \(\) is saved and can be refereced with
\1 to \9 for each \(\).
HTH Chris
Christoph Spohr
View Public Profile
Find all posts by Christoph Spohr
Find Christoph Spohr's past nominations received
Find Christoph Spohr's present nominations given