![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| parsing a string in a shell script | asutoshch | Shell Programming and Scripting | 19 | 05-26-2008 10:18 PM |
| Parsing a line in Shell Script | unishiva | Shell Programming and Scripting | 3 | 11-01-2007 04:30 PM |
| Help in parsing a CSV file with Shell script | mihirk | Shell Programming and Scripting | 10 | 06-24-2007 11:58 AM |
| Parsing a file in Shell Script | sendhilmani123 | Shell Programming and Scripting | 4 | 11-30-2006 02:29 AM |
| shell script argument parsing | rmjoe | Shell Programming and Scripting | 1 | 07-28-2005 04:37 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
#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! ![]() |
|
||||
|
OK, I have the first two parts done, the following sed arguments produce the output I need, but I dont know how to insert the - symbol before the IP's. Anyone got any ideas?
#!/bin/sh whois $1 | grep "Name Server"|sed "s/ //" dig +short $1 mx|sed "s/[0-9][0-9] /+/" 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 +smtp3.google.com. +smtp4.google.com. +smtp1.google.com. +smtp2.google.com. googlemail.l.google.com. 66.249.83.83 66.249.83.19 |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|