output comparison from 2 files

output comparison from 2 files

Post by sweinber » Thu, 04 Mar 1999 04:00:00



Hi.  I'm just beginning with shell programming.  The situation is as
follows:  I have a program that controls that our systems are on-line
(via ping).  The output is written to a file.  Now we want to modify the
script so that is the system goes off-line that we don't continually get
messages (every hour from the crontab) that the system still is
off-line, but once when it goes off-line and once again when the system
is on-line again.

So, I was thinking if I have a out file named current and  another
called history and a comparison was made between the contents of the two
files and depending if the system is offline or on-line.  This is
unfortunately a little ahead of my current knowledge.  I know how to do
basic do/done loops and if statements but this is a little too advance
for me.

I would very much appreciate it if someone could point me in the right
direction with some tips.

thanks in advance for your help!

Sandy.

 
 
 

output comparison from 2 files

Post by Barry Margoli » Thu, 04 Mar 1999 04:00:00




>So, I was thinking if I have a out file named current and  another
>called history and a comparison was made between the contents of the two
>files and depending if the system is offline or on-line.  This is
>unfortunately a little ahead of my current knowledge.  I know how to do
>basic do/done loops and if statements but this is a little too advance
>for me.

Take a look at the diff and cmp commands.  Something like this could be
useful:

if cmp -s history current; then
  echo No change
else
  echo Something has changed
  diff -c history current
fi

--

GTE Internetworking, Powered by BBN, Burlington, MA
*** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to newsgroups.
Please DON'T copy followups to me -- I'll assume it wasn't posted to the group.

 
 
 

1. output comparison

I want to compare the output of 2 commands and report on what is
different between the two.  Redirecting both to a file and diff'ing
won't work as the first thing missing in one output could be the
second line, in which case the whole damn file is different.

I need to be able to report on what is missing from output2, and only
what is missing.  The specific example is this:

First output:
sudo rsh filer1 qtree | cut -f2 | sort

This will give me a list of names

Second output:
sudo rsh filer2 snapmirror status | cut -d/ -f4 | sort

This will also give me a list of names.

In this example I want to see what is missing from output 2, all in
one fluid script.  I'm sure it's possible but I can't find how.  Any
pointers?

Thanks.

~F

2. Public-Key Cryptography Standard library + headers.

3. Perl script log file output has duplicate copies of output lines

4. smoothwall GPL VPN routing problem

5. Outputting to a log file and translating output

6. Q: 3.2v4.2 with greater than 1024 ctlinders problem

7. file manipulation to get several output file out of 1 file

8. dhcp + samba

9. how to direct standard output and error output to the same file in tcsh

10. ERROR: Open Output File, DETAIL: 0 FILE: SystemCmd.cc LINE 484

11. sed input file to output file

12. How to output file's timestamp when print file in UNIX?

13. Create batch file and send screen output to a file