home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / comp / sys / hp / 9367 < prev    next >
Encoding:
Internet Message Format  |  1992-08-17  |  1.5 KB

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