Sign up ×

I need these two commands to be one (so I can pipe them further):

dig +nottlid -t any | egrep -v "^;;|^;|^$" | sort

I mean I need the output of these two commands to be in one pipe:

$ dig +nottlid -t any | egrep -v "^;;|^;|^$" | sort         IN  A         IN  MX  10         IN  NS         IN  NS         IN  NS         IN  NS         IN  SOA 2011053000 28800 7200 604800 14400


dig +nottlid -t any | egrep -v "^;;|^;|^$" | sort         IN  NS         IN  NS     IN  A

so that I could sha256sum them together, without writing the output of the two commands to one file, and sha256sum the file.

Q: it's like this:

echo hi | echo hi2 | sha256sum

of course this won't work, but are there any solutions for this? So that I need the sha256sum of:


but I can only have the outputs from different commands [mentioned above, 2 different domains]. [Just want to write a "DNS checker" script to warn me when DNS records changes for a domain]

share|improve this question

3 Answers 3

up vote 14 down vote accepted

You can pass multiple names to dig:

share|improve this answer
wow, what a feature! –  LanceBaynes Oct 30 '11 at 17:36

A general solution is the following:

{ command1; command2; } | some-other-command
share|improve this answer
Or ( command1; command2; ) | some-other-command. –  hlovdal Oct 31 '11 at 6:57
@hlovdal: yes, but in such a case you are running a subshell (someone would prefer to know), and the second ; is not required. –  enzotib Oct 31 '11 at 7:56

There's two ways to get exactly that output without grepping:

Turn off the sections you don't want:

dig +nottlid +nocomments +noquestion +nostats +nocmd -t any

Turn off all the sections then turn on the sections you do want:

dig +nottlid +noall +authority +answer +additional -t any

Also, it seems the output gives a different additional (or "glue") section each time, so you might want to use +noadditional if you're just trying to check for changes to the zone file.

share|improve this answer

Your Answer


