As sed works line by line there is no simple way to tell sed use the latest occurrence in the file (well at least I didn't find that). So my approach is a bit complicated but works well:
reverse file and replace node version with a temporary string
reverse file back and then reverse temporary string with what we need
The issue in update.sh was due $ is treated as address and means end of file in this line:
As sed works line by line there is no simple way to tell sed use the latest occurrence in the file (well at least I didn't find that). So my approach is a bit complicated but works well:
-ap