#I'm quite new to scripting and my boss has asked me to solve a simple problem and sadly, I can't figure out how to do it. Any help is appreciated.
#The following is a small shell script and the output that it produces for google.com.
#!/bin/sh
whois $1 | grep "Name Server"
dig +short $1 mx
dig +short mail.$1
[jjamd64@localhost ~]$ ./dn.sh google.com
Name Server: NS1.GOOGLE.COM
Name Server: NS2.GOOGLE.COM
Name Server: NS3.GOOGLE.COM
Name Server: NS4.GOOGLE.COM
10 smtp3.google.com.
10 smtp4.google.com.
10 smtp1.google.com.
10 smtp2.google.com.
googlemail.l.google.com.
66.249.83.83
66.249.83.19
#I need to modify this script so that it deletes the spaces in the beginning of the "name server" line, deletes the numbers and space before the mx records and replaces with a + symbol, and places a - symbol before the IP's. Here is what it should look like:
[jjamd64@localhost ~]$ ./dn.sh google.com
Name Server: NS1.GOOGLE.COM
Name Server: NS2.GOOGLE.COM
Name Server: NS3.GOOGLE.COM
Name Server: NS4.GOOGLE.COM
+smtp3.google.com.
+smtp4.google.com.
+smtp1.google.com.
+smtp2.google.com.
googlemail.l.google.com.
-66.249.83.83
-66.249.83.19
#I would like to use the sed command if possible and any hints would be much appreciated. I'm open to other suggestions as long as it produces the desired output. I really appreciate any direction and tips. THANKS!