Regex match in shell script -


i'm writing shell script makes sure dns server looking. here's output tests:

server:         127.0.0.1 address:        127.0.0.1#53  name:   galapagos.office address: 192.168.140.25 

everything "galapagos.office" needs match exactly. "galapagos.office" part doesn't matter @ all.

i figure can apply regex output tell me if looks how want:

server: +127\.0\.0\.1\naddress: +127\.0\.0\.1#53\n\nname:.+\naddress: 192\.168\.140\.25 

the thing don't know shell scripting. what's best way make sure regex matches output of nslookup command?

just guess of want

awk '/server/&&$2=="127.0.0.1"{f=1}        /address/&&$2=="127.0.0.1#53"{g=1}        /address/&&$2=="192.168.140.25"{h=1}   end{if(h && g && f) print "ok"}' file 

Comments

Popular posts from this blog

c++ - Convert big endian to little endian when reading from a binary file -

C#: Application without a window or taskbar item (background app) that can still use Console.WriteLine() -

unicode - Are email addresses allowed to contain non-alphanumeric characters? -