I have three files, two files with 2259 IP addresses in each file. One file with 137772. The script uses sed with bash arrays and a for loop to replace the IPs in an access.log with different IPs. After several hours of running the script fails with this error:
sed: -e expression #1, char 0: no previous regular expression
The number of uniq IP addresses is also short by six IPs.
Here is the script:
#!/bin/bash
_ORGIFS=$IFS
IFS=$'\n'
_alIPs=($(<access.log.IPs)
_fIPs=($(<randomIPs.txt)
for (( _i=1; _i<=2259; _i++ ))
do
sed -i "s/${_alIPs[$_i]}/${_fIPs[$_i]}/g" access.log
done
IFS=$_ORGIFS