Hi,
sed 's%=".*" >\(.*\)</%="\1" >\1</%' infile
Sample run:
Code:
$ sed 's%=".*" >\(.*\)</%="\1" >\1</%' infile
<option value="AFGHANISTAN" >AFGHANISTAN</option>
<option value="ALBANIA" >ALBANIA</option>
<option value="ALGERIA" >ALGERIA</option>
<option value="ANDORRA" >ANDORRA</option>
<option value="ANGOLA" >ANGOLA</option>
<option value="CAYMAN ISLANDS" >CAYMAN ISLANDS</option>
<option value="UNITED STATES OF AMERICA" >UNITED STATES OF AMERICA</option>
In case you don't understand the sed command, here's a little breakdown:
You are not bound to the / as separator. I used the % because there are forward slashes in the infile.
I also used backreferencing, the string found between
\( and
\) in the search part can be used in the replace part as
\1.
=".*" >\(.*\)</ => search part.
="\1" >\1</%' => replace part.
An example:
If this
<option value="AL" >ALBANIA</option> is your input line, the search part will 'cut out'
="AL" >ALBANIA</, ALBANIA (the \(.*\) part) can be represented as \1 in the replace part.
If anything is unclear, just ask.