i m searching a zone file my domain name is abcd.com
my zone file looks like this.
abcd.com. IN SOA ns1.abcd.com. root.abcd.com. (
abcd.com. 400 IN A 15.1.1.1
Then i am searching that abcd.com have if below ip address or not, if not then echo ip address is different. But problem is that i am not able to search the domain name with ip address because domain name is also having SOA record. abcd.com.zone is file name of zone file.
grep -q "^abcd\.com.*15\.1\.1\.10" file && echo zone-IP found || echo ip address is different.
will also say that the IP was found for IP addresses 15.1.1.100 through 15.1.109 in addition to 15.1.1.10. Assuming there is no whitespace at the end of the line, you might want to try:
grep -q "^abcd\.com.*15\.1\.1\.10$" file && echo zone-IP found || echo ip address is different.
Yes true, but i have one question, for first and second both record you are breaking source ip address in block while target ip address you are not breaking... why?
---------- Post updated at 04:37 PM ---------- Previous update was at 04:32 PM ----------
One more thing, how i can add increment in serial number.
In sed 's s(ubstitute) comamnd, the first term is a regex so you need to escape the dots (if you want to be very accurate), while the second is just plain text (except for e.g. \n).
If you want to do arithmetics, you'd be better off utilising tools like awk or perl , where you can modify the IPs as well as serial No.s in one single script.
I agree to what others say: show us your efforts, and we'll be glad to help. First effort would be to compose a clear and unambiguous specification of what you need and where you come from. This effort would be rewarding by increasing chances for yourself to solve the problem on your own.
Try to search these forums for examples of using awk to perform some arithmetics. But be aware that your desire is not to just increase a "serial number" but that this serial number has some structure (YYMMDDNN) to it: What should happen if NN exceeds 99? What if you modify a file that was last modified yesterday? last month? year?