I am wondering how Bash can solve the next exercise. I have a set of config files in one directory where some IP addresses pointed out. E.g:
conf1.txt
:
ip-addr: 192.168.1.2;
mask...;
gateway...;
another ip-addr: 192.168.1.5;
one more ip-addr: 192.168.1.10;
...
conf2.txt
:
ip-addr: 192.168.1.2;
mask...;
gateway...;
another ip-addr: 192.168.1.5;
one more ip-addr: 192.168.1.10;
...
And the question is: How can I change all IP addresses with another pool of IP addresses (192.168.1.100-192.168.1.254) but in all files. So for example:
- 192.168.1.2 -> 192.168.1.100
- 192.168.1.5 -> 192.168.1.101
- 192.168.1.10 ->192.168.1.102
I suppose that there is some mechanism of assigning values from one array to another because hardcoded version like:
sed "s/192.168.1.2/192.168.1.100/g";
Isn't good.