Add the DragonFly cvs id and perform general cleanups on cvs/rcs/sccs ids. Most
[dragonfly.git] / usr.bin / truncate / truncate.1
1 .\"
2 .\" Copyright (c) 2000 Sheldon Hearn <sheldonh@FreeBSD.org>.
3 .\" All rights reserved.
4 .\"
5 .\" Redistribution and use in source and binary forms, with or without
6 .\" modification, are permitted provided that the following conditions
7 .\" are met:
8 .\" 1. Redistributions of source code must retain the above copyright
9 .\"    notice, this list of conditions and the following disclaimer.
10 .\" 2. Redistributions in binary form must reproduce the above copyright
11 .\"    notice, this list of conditions and the following disclaimer in the
12 .\"    documentation and/or other materials provided with the distribution.
13 .\"
14 .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 .\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 .\" SUCH DAMAGE.
25 .\"
26 .\" $FreeBSD: src/usr.bin/truncate/truncate.1,v 1.4.2.7 2001/08/16 13:17:08 ru Exp $
27 .\" $DragonFly: src/usr.bin/truncate/truncate.1,v 1.2 2003/06/17 04:29:33 dillon Exp $
28 .\"
29 .Dd July 4, 2000
30 .Dt TRUNCATE 1
31 .Os
32 .Sh NAME
33 .Nm truncate
34 .Nd truncate or extend the length of files
35 .Sh SYNOPSIS
36 .Nm
37 .Op Fl c
38 .Bk -words
39 .Fl s Xo
40 .Sm off
41 .Op Cm + | -
42 .Ar size
43 .Op Cm K | M | G
44 .Sm on
45 .Xc
46 .Ek
47 .Ar
48 .Nm
49 .Op Fl c
50 .Bk -words
51 .Fl r Ar rfile
52 .Ek
53 .Ar
54 .Sh DESCRIPTION
55 The
56 .Nm
57 utility adjusts the length of each regular file given on the command-line.
58 .Pp
59 The following options are available:
60 .Bl -tag -width indent
61 .It Fl c
62 Do not create files if they do not exist.
63 The
64 .Nm
65 utility does not treat this as an error.
66 No error messages are displayed
67 and the exit value is not affected.
68 .It Fl r Ar rfile
69 Truncate files to the length of the file
70 .Ar rfile .
71 .It Fl s Xo
72 .Sm off
73 .Op Cm + | -
74 .Ar size
75 .Op Cm K | M | G
76 .Sm on
77 .Xc
78 If the
79 .Ar size
80 argument is preceded by a plus sign
81 .Pq Cm + ,
82 files will be extended by this number of bytes.
83 If the
84 .Ar size
85 argument is preceded by a dash
86 .Pq Cm - ,
87 file lengths will be reduced by no more than this number of bytes,
88 to a minimum length of zero bytes.
89 Otherwise, the
90 .Ar size
91 argument specifies an absolute length to which all files
92 should be extended or reduced as appropriate.
93 .Pp
94 The
95 .Ar size
96 argument may be suffixed with one of
97 .Cm K ,
98 .Cm M
99 or
100 .Cm G
101 to indicate a multiple of
102 Kilobytes, Megabytes or Gigabytes
103 respectively.
104 .El
105 .Pp
106 Exactly one of the
107 .Fl r
108 and
109 .Fl s
110 options must be specified.
111 .Pp
112 If a file is made smaller, its extra data is lost.
113 If a file is made larger,
114 it will be extended as if by writing bytes with the value zero.
115 If the file does not exist,
116 it is created unless the
117 .Fl c
118 option is specified.
119 .Pp
120 Note that,
121 while truncating a file causes space on disk to be freed,
122 extending a file does not cause space to be allocated.
123 To extend a file and actually allocate the space,
124 it is necessary to explicitly write data to it,
125 using (for example) the shell's
126 .Ql >>
127 redirection syntax, or
128 .Xr dd 1 .
129 .Sh DIAGNOSTICS
130 .Ex -std
131 If the operation fails for an argument,
132 .Nm
133 will issue a diagnostic
134 and continue processing the remaining arguments.
135 .Sh SEE ALSO
136 .Xr dd 1 ,
137 .Xr touch 1 ,
138 .Xr truncate 2
139 .Sh STANDARDS
140 The
141 .Nm
142 utility conforms to no known standards.
143 .Sh HISTORY
144 The
145 .Nm
146 utility first appeared in
147 .Fx 4.2 .
148 .Sh AUTHORS
149 The
150 .Nm
151 utility was written by
152 .An Sheldon Hearn
153 .Aq sheldonh@starjuice.net .