Combining dig +short command

What do you mean by 'ouput in one display'?

I can almost not imagine this being the actual answer due to the simplicity, but based on what I assume is your answer now, this should do the trick:

dig @ns1.myname.com myname.com +short MX; dig @ns1.myname.com myname.com +short A

You can simply queue several commands in one line by separating them with a semicolon.


dig +noall +answer @ns1.myname.com myname.com ANY

You can grep out the types you need if you don't want all of them, or query for each one you want in turn.


You can combine them into one command with no semicolon, but as noted in another question, it will still send 2 queries to the server (not a problem here):

dig @ns1.myname.com myname.com +short MX @ns1.myname.com myname.com +short A

You can "reuse" the dig command and keep sending new query parameters in quartets (URL, server to query, query type, query option) as long as you are giving it enough information to run a query on each quartet. More simpler still, you only need to specify the server and query option once, so this works:

dig +short @ns1.myname.com myname.com MX myname.com A

If you need only one query for some reason, you can use ANY with dig (make sure you are querying the authoritative server, not a recursive server's cache) and grep out the answers with the -E option:

dig +noall +answer @ns1.myname.com myname.com MX myname.com A | grep -E '[[:space:]]A[[:space:]]|MX[[:space:]]'

Note: you cannot use +short with this route as it removes the record type you need to use grep on.

Tags:

Dig