gawk - Find and update a numbering in a html file with awk -
i trying update numbering/numeration in test.html file:
<td class="no">(8)</td> <td class="no">(9)</td> <td class="no">(10)</td> <td class="no">(11)</td> <td class="no">(23)</td> a new line added between other lines, don't want update numeration manually. condition is, update should start after number 7.
i tried use gensub replacing line match doesn't work how thought. there must easier way determine numbers! no tutorials or forum posts did me or didn't understand them...
so far have:
/^<td class="no">\([0-9]+\)<\/td>$/ { = gensub(/(.*)([0-9]+)(.*)/, "\\2", "g") # finds 1 digit, why? if (a > 7) print }
if need determine numbers, must rid of character not being digit
/^<td class="no">\([0-9]+\)<\/td>$/ { gsub("[^0-9]","") if ((0+$0) > 7) print } update: (0+$0) > 7 replaces original $0 > 7 because cygwing gawk not compare $0 , 7 numerical values string values --- not know why. i'm not familiar cygwin.
this solution prints following output:
8 9 10 11 23 if test.html file had contained line like
<td class="no">(71)</td> the original code ($0 > 7) have print
71 in cygwin.
Comments
Post a Comment