home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!dtix!darwin.sura.net!mips!sdd.hp.com!usc!hacgate!mobej
- From: mobej@thaad-1g%hac2arpa.hac.com (Mario Obejas)
- Newsgroups: comp.sys.hp
- Subject: Re: diff to return a value in a shell script?
- Message-ID: <22921@hacgate.SCG.HAC.COM>
- Date: 18 Aug 92 00:03:37 GMT
- References: <yy9mlkb.kc@netcom.com>
- Sender: news@hacgate.SCG.HAC.COM
- Lines: 31
- X-Newsreader: Tin 1.1 PL4
-
- kc@netcom.com (Dameon D. Welch) writes:
- : I'm writing a shell script under HP/UX 8.07 that will preform its task
- : if and only if any changes were made to the file. I need to have diff
- : somehow return only an integer value or some other method of determining
- : an error, no differences, or that there are diffs. I've read the man
- : page on diff and it does not specify an option to get what I want.
- :
- : Any ideas?
-
- I know the following works for ascii files, not sure about binary but it should
- work. ASCII was tested before posting.
-
- #!/bin/csh
- #
- # $1 and $2 are the name of the two files being compared
- #
- set lines_changed=`diff $1 $2 | wc -l`
- echo "lines changed =($lines_changed)"
- if ( $lines_changed > '0' ) then
- echo "$1 and $2 are different "
- endif
-
-
- Do I get a chocolate chip cookie for this?
-
- --
- Mario Obejas mobej@thaad-1g.hac.com (714) 732 2954
- mobej@thaad-1g@hac2arpa.hac.com if the above doesn't work
- Hughes Ground Systems Group, P.O. Box 3310, Fullerton, CA 92634
- ex-THAAD sysadmin: will work for food or Internet address
- Disclaimer: my opinions are mine, not necessarily my employer's.
-