This question already has an answer here:
- How can I replace a string in a file(s)? 7 answers
Lets say I have a string that can be any possible/valid network address like so:
What I want to do is replace the last octet (in this case it's 0/24, however it can be anyting) with the number 2, however I don't know what the last octet could (do not will be print the new value, so change:
Whatever the network address is, I want to replace the last octet with "2"
Note: it is not important to check if the string is a valid network address as all strings being tested are assumed to be valid network addresses.