11

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   193.239.149.1
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

and

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   193.239.149.1

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:

hi
hi2
-->>
697ec886148d94d5b094df14f301f2e5a4abd8098a0e0dc2afb0a97945cea677

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]

0

3 Answers 3

33

A general solution is the following:

{ command1; command2; } | some-other-command
2
  • Or ( command1; command2; ) | some-other-command.
    – hlovdal
    Oct 31, 2011 at 6:57
  • 4
    @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, 2011 at 7:56
14

You can pass multiple names to dig:

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

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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .