From owner-svn-src-all@freebsd.org Fri Jun 19 06:48:17 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 48BE4341615; Fri, 19 Jun 2020 06:48:17 +0000 (UTC) (envelope-from fernape@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 49p8X11Bs2z4d3C; Fri, 19 Jun 2020 06:48:17 +0000 (UTC) (envelope-from fernape@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 246AB16BDD; Fri, 19 Jun 2020 06:48:17 +0000 (UTC) (envelope-from fernape@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 05J6mHQA026233; Fri, 19 Jun 2020 06:48:17 GMT (envelope-from fernape@FreeBSD.org) Received: (from fernape@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 05J6mHeq026232; Fri, 19 Jun 2020 06:48:17 GMT (envelope-from fernape@FreeBSD.org) Message-Id: <202006190648.05J6mHeq026232@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: fernape set sender to fernape@FreeBSD.org using -f From: =?UTF-8?Q?Fernando_Apestegu=c3=ada?= Date: Fri, 19 Jun 2020 06:48:17 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r362367 - head/usr.bin/diff X-SVN-Group: head X-SVN-Commit-Author: fernape X-SVN-Commit-Paths: head/usr.bin/diff X-SVN-Commit-Revision: 362367 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 19 Jun 2020 06:48:17 -0000 Author: fernape (ports committer) Date: Fri Jun 19 06:48:16 2020 New Revision: 362367 URL: https://svnweb.freebsd.org/changeset/base/362367 Log: diff(1): Add EXAMPLES section Add examples for -r, -u, -N, -x, -q and -I Approved by: 0mp@ Differential Revision: https://reviews.freebsd.org/D25345 Modified: head/usr.bin/diff/diff.1 Modified: head/usr.bin/diff/diff.1 ============================================================================== --- head/usr.bin/diff/diff.1 Fri Jun 19 06:35:57 2020 (r362366) +++ head/usr.bin/diff/diff.1 Fri Jun 19 06:48:16 2020 (r362367) @@ -30,7 +30,7 @@ .\" @(#)diff.1 8.1 (Berkeley) 6/30/93 .\" $FreeBSD$ .\" -.Dd June 1, 2020 +.Dd June 19, 2020 .Dt DIFF 1 .Os .Sh NAME @@ -277,8 +277,7 @@ Produces a script similar to that of .Fl e , but in the opposite order and with a count of changed lines on each insert or delete command. -This is the form used by -.Xr rcsdiff 1 . +This is the form used by rcsdiff. .It Fl q -brief Just print a line when the files differ. Does not output a list of changes. @@ -613,6 +612,49 @@ Differences were found. .It >1 An error occurred. .El +.Sh EXAMPLES +Compare +.Pa old_dir +and +.Pa new_dir +recursively generating an unified diff and treating files found only in one +of those directories as new files: +.Bd -literal -offset indent +$ diff -ruN /path/to/old_dir /path/to/new_dir +.Ed +.Pp +Same as above but excluding files matching the expressions +.Dq *.h +and +.Dq *.c : +.Bd -literal -offset indent +$ diff -ruN -x '*.h' -x '*.c' /path/to/old_dir /path/to/new_dir +.Ed +.Pp +Show a single line indicating if the files differ: +.Bd -literal -offset indent +$ diff -q /boot/loader.conf /boot/defaults/loader.conf +Files /boot/loader.conf and /boot/defaults/loader.conf differ +.Ed +.Pp +Assuming a file named +.Pa example.txt +with the following contents: +.Bd -literal -offset indent +FreeBSD is an operating system +Linux is a kernel +OpenBSD is an operating system +.Ed +.Pp +Compare stdin with +.Pa example.txt +excluding from the comparison those lines containing either +.Qq Linux +or +.Qq Open : +.Bd -literal -offset indent +$ echo "FreeBSD is an operating system" | diff -q -I 'Linux|Open' example.txt - +.Ed .Sh SEE ALSO .Xr cmp 1 , .Xr comm 1 ,