'diff' option like 'grep -q'?

'diff' option like 'grep -q'?

Post by Ed Moo » Thu, 09 Mar 1995 13:41:03



I need a way to compare two large files to see if they are identical.
grep's -q option is sort of the reverse of what I need.

      -q             (Quiet) Do not write anything to the standard output,
                     regardless of matching lines.  Exit with zero status
                     upon finding the first matching line.

I want diff (or whatever command) to exit upon finding the first non-
matching bits.  How?

Thanks,

Ed Moore
Hewlett-Packard
Vancouver, WA, USA

 
 
 

'diff' option like 'grep -q'?

Post by Andreas Schw » Thu, 09 Mar 1995 23:03:57


|> I need a way to compare two large files to see if they are identical.
|> grep's -q option is sort of the reverse of what I need.

|>       -q       (Quiet) Do not write anything to the standard output,
|>                regardless of matching lines.  Exit with zero status
|>                upon finding the first matching line.

|> I want diff (or whatever command) to exit upon finding the first non-
|> matching bits.  How?

NAME
     cmp - perform a byte-by-byte comparison of two files.

OPTIONS
     -s   Silent. Print nothing for  differing  files;  set  exit
          codes only.

DIAGNOSTICS
     Exit code 0 is returned for identical files, 1 for different
     files,  and  2 for an inaccessible or missing argument, or a
     system error.
--
Andreas Schwab                                      "And now for something


 
 
 

'diff' option like 'grep -q'?

Post by hamilton on B » Fri, 10 Mar 1995 05:47:52



>I need a way to compare two large files to see if they are identical.
>grep's -q option is sort of the reverse of what I need.
>      -q         (Quiet) Do not write anything to the standard output,
>                 regardless of matching lines.  Exit with zero status
>                 upon finding the first matching line.
>I want diff (or whatever command) to exit upon finding the first non-
>matching bits.  How?

Use the cmp utility.  By default, it stops at the first mismatch, printing
the offset and line number.  If you want a silent compare that just sets
the exit code (0 if identical, 1 if different), use the -s option.

Regards,

Hamilton Laboratories, 21 Shadow Oak Drive, Sudbury, MA  01776-3165, USA

 
 
 

1. '-i' option for 'cp' and 'mv'

I am using a system running System V on a 386 machine.  In 4.3 bsd, 'cp'
and 'mv' have the option '-i' which will warn me if the file exists.
In the system I am using, only 'rm' has such an option.   I would like to change
it so that '-i' will work for 'cp' and 'mv' as well.  Can someone tell me how to
do it?

Many thanks

philip

2. SCSI options for AIC7xxx

3. grep octal value (grep '\0145' /tmp/test) doesn't work !!

4. New Program

5. Combining 'find' and 'grep' or searching in general

6. Second line printer on Xenix

7. Q: grep 'foo' NOT followed by 'bar'

8. Pipe command output to listbox

9. menu option 'Y' or 'y'

10. in 'getopt()', how to handle multiple options in the 'optarg' string?

11. XF86Config: 'EarlySC','BlankDelay' options gone?

12. 'netstat' and '-f inet' option