Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

Just for editing Wiki's..

So i have this input [from a larget text]:

TEXT TEXT BLA-BLA RANDOMSTRINGS BLA-BLA
TEXT TEXT BLA-BLA RANDOMSTRINGS BLA-BLA
TEXT TEXT <a href="http://xy.com">XY</a> RANDOMSTRINGS BLA-BLA
TEXT TEXT BLA-BLA RANDOMSTRINGS BLA-BLA
TEXT TEXT BLA-BLA RANDOMSTRINGS BLA-BLA

and i want this output:

TEXT TEXT BLA-BLA RANDOMSTRINGS BLA-BLA
TEXT TEXT BLA-BLA RANDOMSTRINGS BLA-BLA
TEXT TEXT [http://xy.com XY] RANDOMSTRINGS BLA-BLA
TEXT TEXT BLA-BLA RANDOMSTRINGS BLA-BLA
TEXT TEXT BLA-BLA RANDOMSTRINGS BLA-BLA

"http://xy.com" could be e.g.: "https://xy.com" or "http://www.xy.com" or "https://www.xy.com", etc.

share|improve this question

1 Answer 1

up vote 1 down vote accepted

Without attempting to detect troublesome input (e.g. link or text containing []), just capture everything between the "…" and between >…</a>:

sed -e 's!<a  *href *= *"\([^"]*\)" *>\([^<>]*\)</[Aa]>![\1 \2]!g'
share|improve this answer
    
who are you? some kind of god? :D THANK YOU! –  LanceBaynes Apr 16 '11 at 14:21

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.