Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

dig +nottlid -t any bix.hu | egrep -v "^;;|^;|^$" | sort
dig +nottlid -t any www.bix.hu | egrep -v "^;;|^;|^$" | sort

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

$ dig +nottlid -t any bix.hu | egrep -v "^;;|^;|^$" | sort
bix.hu.         IN  A
bix.hu.         IN  MX  10 deneb.iszt.hu.
bix.hu.         IN  NS  ns.iszt.hu.
bix.hu.         IN  NS  ns.iszt.hu.
bix.hu.         IN  NS  ns-s.nic.hu.
bix.hu.         IN  NS  ns-s.nic.hu.
bix.hu.         IN  SOA ns.iszt.hu. hostmaster.iszt.hu. 2011053000 28800 7200 604800 14400


dig +nottlid -t any www.bix.hu | egrep -v "^;;|^;|^$" | sort
bix.hu.         IN  NS  ns.iszt.hu.
bix.hu.         IN  NS  ns-s.nic.hu.
www.bix.hu.     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
up vote 14 down vote accepted

You can pass multiple names to dig:

dig +nottlid -t any bix.hu www.bix.hu | egrep -v "^;;|^;|^$" | sort
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 bix.hu

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

dig +nottlid +noall +authority +answer +additional -t any bix.hu

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


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.