bash - sed match on first instance not working -


i want replace first instance of <tr> <tr class="active"> using shell (bash).

however, sed has no affect:

sed '0,/<tr>/s/<tr>/<tr class="active">/' file1 >> temp2.txt 

temp2.txt remains

<tr>   <th>set</th>   <th>run</th>   <th>continuum<br>filter</th>   <th>narrow band<br>filter</th> </tr> <tr>   <td><a href="#set1">1</a></td>   <td>run09</td>   <td>r_harris</td>   <td>6605/32</td> </tr> 

whereas code changes both first , second instance of <tr>

sed '1,/<tr>/s/<tr>/<tr class="active">/' file1 >> temp2.txt 

can explain what's going on?

<tr class="active">     <th>set</th>     <th>run</th>     <th>continuum<br>filter</th>     <th>narrow band<br>filter</th> </tr> <tr class="active">     <td><a href="#set1">1</a></td>     <td>run09</td>     <td>r_harris</td>     <td>6605/32</td> </tr> 

try following command.

sed -e '1,/<tr>/ s/<tr>/<tr class="active">/' 

this command substitute < tr > < tr class="active" >

from line number 1 first line < tr > found.


Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -