I need to get the index of the last occurrence of a pattern. Tried ideas from here and here. The below does not work if I want the index of the last : (index is 6). Tried to use the anchor $ but clearly have not grasped it (since it gives me the first occurrence, i.e. 3). Explanations really appreciated.
echo 12:45:78 |
awk '
{
print match($1, /:.+$/)
}'