Date: Tue, 16 Jun 2020 15:55:00 +0000 (UTC) From: =?UTF-8?Q?Fernando_Apestegu=c3=ada?= <fernape@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r362229 - head/usr.bin/cmp Message-ID: <202006161555.05GFt03C084528@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: fernape (ports committer) Date: Tue Jun 16 15:54:59 2020 New Revision: 362229 URL: https://svnweb.freebsd.org/changeset/base/362229 Log: cmp(1): Add EXAMPLES section Add simple examples showing the use of -l, -z, stdin and offsets Approved by: bcr@ Differential Revision: https://reviews.freebsd.org/D25280 Modified: head/usr.bin/cmp/cmp.1 Modified: head/usr.bin/cmp/cmp.1 ============================================================================== --- head/usr.bin/cmp/cmp.1 Tue Jun 16 14:02:51 2020 (r362228) +++ head/usr.bin/cmp/cmp.1 Tue Jun 16 15:54:59 2020 (r362229) @@ -31,7 +31,7 @@ .\" @(#)cmp.1 8.1 (Berkeley) 6/6/93 .\" $FreeBSD$ .\" -.Dd May 1, 2018 +.Dd June 16, 2020 .Dt CMP 1 .Os .Sh NAME @@ -106,6 +106,40 @@ file (before any differences were found). .It >1 An error occurred. .El +.Sh EXAMPLES +Assuming a file named example.txt with the following contents: +.Bd -literal -offset indent +a +b +c +.Ed +.Pp +Compare stdin with example.txt: +.Bd -literal -offset indent +$ echo -e "a\\nb\\nc" | cmp - example.txt +.Ed +.Pp +Same as above but introducing a change in byte three in stdin. +Show the byte number (decimal) and differing byte (octal): +.Bd -literal -offset indent +$ echo -e "a\\nR\\nc" | cmp -l - example.txt + 3 122 142 +.Ed +.Pp +Compare example.txt and /boot/loader.conf exiting if size differs. +Note that +.Fl z +can only be used with regular files: +.Bd -literal -offset indent +$ cmp -z example.txt /boot/loader.conf +example.txt /boot/loader.conf differ: size +.Ed +.Pp +Compare stdin with file example.txt omitting the 4 first bytes from stdin and +the 2 first bytes from example.txt: +.Bd -literal -offset indent +$ echo -e "a\\nR\\nb\\nc" | cmp - example.txt 4 2 +.Ed .Sh SEE ALSO .Xr diff 1 , .Xr diff3 1
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202006161555.05GFt03C084528>