I need to change an IP-address in a text-file using linux-shell. How can I do that? Do you know a great source for regular expressions?
the textfile.txt contains sth like this:
# text text ffeefe
Whatever text text ffeefe
# text text ffeefe
#
IPAddress : 192.168.200.40
#
# text text ffeefe
#
Whatever text text ffeefe
# text text ffeefe
This is what I am looking for:
sed -i / find XXX.XXX.XXX.XXX / 192.168.200.41 / textfile.txt
The IP could be anything in that format XXX.XXX.XXX.XXX e.g. 192.168.200.40
Although fedorqui is right with asking more information about occurring of IP after specific content, I'll provide (easy) solution for finding any IPv4 string.
The expression is:
using it in sed looks like this:
On the other hand, if this is fixed "IPAddress : " before IP, then the OP should just use the IP they want.