Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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]

share|improve this question
add comment

3 Answers

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
add comment

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
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 '11 at 7:56
add comment

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
add comment

Your Answer

 
discard

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.