awk to substitute ip without zero left padding

view full story

http://www.unix.com – Hello All, I have this script to awk IP to new file. #awk '/myip|yourip/ {sub(/...\....\....\..../, newip)}1' newip=$IP existing.txt > new.txt When existing.txt has myip= and $IP has, the awk script is not working. But while I add zero left padding to $IP i.e, it works. Same the case when myip= and $IP has, does not work. Inshort, the IP format need to be 3 digit decimal to work. Any suggestions. Regards Shaan (HowTos)