The problem is what jschiwal already pointed out: sed will parse the entire file at every call and if you put the sed command inside a loop, you will get the entire file duplicated multiple times (with some substitution made at some point). The problem is
how to increment a numeric variable in sed and use it as the replacement string in the substitution. Since there is not an easy way to do that in sed, the suggested awk code is more handy.
Anyway, to stick with the shell, you can do something like this:
Code:
#!/bin/bash
while read line
do
if [[ $line =~ '*' ]]
then
((count++))
echo ${line/\*/(0.0.0.$count)}
else
echo $line
fi
done < zlit
The if statement check if the line matches a literal asterisk and use substring replacement accordingly. Note that the =~ operator is available from bash version 3 and you may have compatibility issues if you use the code with an older version.