From owner-svn-src-all@freebsd.org  Mon Jul 27 15:25:04 2020
Return-Path: <owner-svn-src-all@freebsd.org>
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 E58C5366278;
 Mon, 27 Jul 2020 15:25:04 +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 4BFkBm5qrXz3fBq;
 Mon, 27 Jul 2020 15:25:04 +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 A880F1FCAC;
 Mon, 27 Jul 2020 15:25:04 +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 06RFP41W012993;
 Mon, 27 Jul 2020 15:25:04 GMT (envelope-from fernape@FreeBSD.org)
Received: (from fernape@localhost)
 by repo.freebsd.org (8.15.2/8.15.2/Submit) id 06RFP4JU012992;
 Mon, 27 Jul 2020 15:25:04 GMT (envelope-from fernape@FreeBSD.org)
Message-Id: <202007271525.06RFP4JU012992@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?= <fernape@FreeBSD.org>
Date: Mon, 27 Jul 2020 15:25:04 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
 svn-src-head@freebsd.org
Subject: svn commit: r363611 - head/usr.bin/truncate
X-SVN-Group: head
X-SVN-Commit-Author: fernape
X-SVN-Commit-Paths: head/usr.bin/truncate
X-SVN-Commit-Revision: 363611
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 &quot;
 user&quot; and &quot; projects&quot; \)" <svn-src-all.freebsd.org>
List-Unsubscribe: <https://lists.freebsd.org/mailman/options/svn-src-all>,
 <mailto:svn-src-all-request@freebsd.org?subject=unsubscribe>
List-Archive: <http://lists.freebsd.org/pipermail/svn-src-all/>
List-Post: <mailto:svn-src-all@freebsd.org>
List-Help: <mailto:svn-src-all-request@freebsd.org?subject=help>
List-Subscribe: <https://lists.freebsd.org/mailman/listinfo/svn-src-all>,
 <mailto:svn-src-all-request@freebsd.org?subject=subscribe>
X-List-Received-Date: Mon, 27 Jul 2020 15:25:05 -0000

Author: fernape (ports committer)
Date: Mon Jul 27 15:25:04 2020
New Revision: 363611
URL: https://svnweb.freebsd.org/changeset/base/363611

Log:
  truncate(1): Add EXAMPLES section
  
  Add four simple examples showing the use of -c, -r and -s
  
  Approved by:	manpages (bcr@)
  Differential Revision: https://reviews.freebsd.org/D25774

Modified:
  head/usr.bin/truncate/truncate.1

Modified: head/usr.bin/truncate/truncate.1
==============================================================================
--- head/usr.bin/truncate/truncate.1	Mon Jul 27 15:09:07 2020	(r363610)
+++ head/usr.bin/truncate/truncate.1	Mon Jul 27 15:25:04 2020	(r363611)
@@ -25,7 +25,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd December 19, 2006
+.Dd July 27, 2020
 .Dt TRUNCATE 1
 .Os
 .Sh NAME
@@ -143,6 +143,43 @@ If the operation fails for an argument,
 .Nm
 will issue a diagnostic
 and continue processing the remaining arguments.
+.Sh EXAMPLES
+Adjust the size of the file
+.Pa test_file
+to 10 Megabytes but do not create it if it does not exist:
+.Bd -literal -offset indent
+truncate -c -s +10M test_file
+.Ed
+.Pp
+Same as above but create the file if it does not exist:
+.Bd -literal -offset indent
+truncate -s +10M test_file
+ls -l test_file
+-rw-r--r--  1 root  wheel  10485760 Jul 22 18:48 test_file
+.Ed
+.Pp
+Adjust the size of
+.Pa test_file
+to the size of the kernel and create another file
+.Pa test_file2
+with the same size:
+.Bd -literal -offset indent
+truncate -r /boot/kernel/kernel test_file test_file2
+ls -l /boot/kernel/kernel test_file*
+-r-xr-xr-x  1 root  wheel    31352552 May 15 14:18 /boot/kernel/kernel*
+-rw-r--r--  1 root  wheel    31352552 Jul 22 19:15 test_file
+-rw-r--r--  1 root  wheel    31352552 Jul 22 19:15 test_file2
+.Ed
+.Pp
+Downsize
+.Pa test_file
+in 5 Megabytes:
+.Bd -literal -offset indent
+# truncate -s -5M test_file
+ls -l test_file*
+-rw-r--r--  1 root  wheel    26109672 Jul 22 19:17 test_file
+-rw-r--r--  1 root  wheel    31352552 Jul 22 19:15 test_file2
+.Ed
 .Sh SEE ALSO
 .Xr dd 1 ,
 .Xr touch 1 ,