Results 1 to 2 of 2
Hi,
what r back refferences in SED..........i.e.,
......
Why do we use these... please explain with an example...
Thanks...
- 06-24-2009 #1Just Joined!
- Join Date
- Apr 2009
- Posts
- 5
SED back references
Hi,
what r back refferences in SED..........i.e., \1 \2 \3......\9
Why do we use these... please explain with an example...
Thanks
- 06-24-2009 #2
back references are useful if you want to match a regular expresion, and replace it with different data that still contains part of what was matched.
I.E. If I use regular expresion to match a html link
<a href="http://www.google.com"> search engine </a>
but I want to strip the html tags, and create a plaintext file with the URL and whatever text was linked, the 'search engine' in this example, I could
cat somefile | sed 's!<a href="(.*)">(.*)</a>!\1::\2!g'
and create a file with 2 field seperated by `::` with the previously mentioned data.New to the internet, technical forums, or the hacker / open source community??
Read this to learn good posting habits http://www.catb.org/~esr/faqs/smart-questions.html
RHCE for RHEL version 5
RHCT for RHEL version 4


Reply With Quote