Retain upto 2 decimal point for numeric values

Hi

I have a big file with lines like below

<tr align="center" bgcolor="SEASHELL"><td>94% </td><td>4.62178 </td><td>73.4375 </td></tr>
<tr align="center" bgcolor="SEASHELL"></td><td>97% </td><td>3.2962 </td><td>125 </td></tr>

I want to format the file such that i get like below. i.e retain upto two point decimal where it sees decimal point

<tr align="center" bgcolor="SEASHELL"></td><td>94% </td><td>4.62 </td><td>73.43 </td></tr>
<tr align="center" bgcolor="SEASHELL"></td><td>97% </td><td>3.29 </td><td>125 </td></tr>

sed 's/\([0-9]\{1,\}[.][0-9][0-9]\)[0-9]\{1,\}/\1/g' file
1 Like

awesome !!works well . I completely dont understand it though..

we can do it like this also..

although it is almost same as elixir...:smiley:

sed 's/\([0-9]\+[.][0-9][0-9]\)[0-9]\{2,\}/\1/g' file