[9] | 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.12 2005/01/17 07:44:32 ru Exp $
|
---|
| 27 | .\"
|
---|
| 28 | .Dd July 4, 2000
|
---|
| 29 | .Dt TRUNCATE 1
|
---|
| 30 | .Os
|
---|
| 31 | .SH NAME
|
---|
| 32 | truncate \- truncate or extend the length of files
|
---|
| 33 | .SH SYNOPSIS
|
---|
| 34 | truncate
|
---|
| 35 | .Op Fl c
|
---|
| 36 | .Bk -words
|
---|
| 37 | .Fl s Xo
|
---|
| 38 | .Sm off
|
---|
| 39 | .Op Cm + | -
|
---|
| 40 | .Ar size
|
---|
| 41 | .Op Cm K | k | M | m | G | g
|
---|
| 42 | .Sm on
|
---|
| 43 | .Xc
|
---|
| 44 | .Ek
|
---|
| 45 | .Ar
|
---|
| 46 | truncate
|
---|
| 47 | .Op Fl c
|
---|
| 48 | .Bk -words
|
---|
| 49 | .Fl r Ar rfile
|
---|
| 50 | .Ek
|
---|
| 51 | .Ar
|
---|
| 52 | .SH DESCRIPTION
|
---|
| 53 | The
|
---|
| 54 | truncate
|
---|
| 55 | utility adjusts the length of each regular file given on the command-line.
|
---|
| 56 | .Pp
|
---|
| 57 | The following options are available:
|
---|
| 58 | .Bl -tag -width indent
|
---|
| 59 | .It Fl c
|
---|
| 60 | Do not create files if they do not exist.
|
---|
| 61 | The
|
---|
| 62 | truncate
|
---|
| 63 | utility does not treat this as an error.
|
---|
| 64 | No error messages are displayed
|
---|
| 65 | and the exit value is not affected.
|
---|
| 66 | .It Fl r Ar rfile
|
---|
| 67 | Truncate files to the length of the file
|
---|
| 68 | .Ar rfile .
|
---|
| 69 | .It Fl s Xo
|
---|
| 70 | .Sm off
|
---|
| 71 | .Op Cm + | -
|
---|
| 72 | .Ar size
|
---|
| 73 | .Op Cm K | k | M | m | G | g
|
---|
| 74 | .Sm on
|
---|
| 75 | .Xc
|
---|
| 76 | If the
|
---|
| 77 | .Ar size
|
---|
| 78 | argument is preceded by a plus sign
|
---|
| 79 | .Pq Cm + ,
|
---|
| 80 | files will be extended by this number of bytes.
|
---|
| 81 | If the
|
---|
| 82 | .Ar size
|
---|
| 83 | argument is preceded by a dash
|
---|
| 84 | .Pq Cm - ,
|
---|
| 85 | file lengths will be reduced by no more than this number of bytes,
|
---|
| 86 | to a minimum length of zero bytes.
|
---|
| 87 | Otherwise, the
|
---|
| 88 | .Ar size
|
---|
| 89 | argument specifies an absolute length to which all files
|
---|
| 90 | should be extended or reduced as appropriate.
|
---|
| 91 | .Pp
|
---|
| 92 | The
|
---|
| 93 | .Ar size
|
---|
| 94 | argument may be suffixed with one of
|
---|
| 95 | .Cm K ,
|
---|
| 96 | .Cm M
|
---|
| 97 | or
|
---|
| 98 | .Cm G
|
---|
| 99 | (either upper or lower case) to indicate a multiple of
|
---|
| 100 | Kilobytes, Megabytes or Gigabytes
|
---|
| 101 | respectively.
|
---|
| 102 | .El
|
---|
| 103 | .Pp
|
---|
| 104 | Exactly one of the
|
---|
| 105 | .Fl r
|
---|
| 106 | and
|
---|
| 107 | .Fl s
|
---|
| 108 | options must be specified.
|
---|
| 109 | .Pp
|
---|
| 110 | If a file is made smaller, its extra data is lost.
|
---|
| 111 | If a file is made larger,
|
---|
| 112 | it will be extended as if by writing bytes with the value zero.
|
---|
| 113 | If the file does not exist,
|
---|
| 114 | it is created unless the
|
---|
| 115 | .Fl c
|
---|
| 116 | option is specified.
|
---|
| 117 | .Pp
|
---|
| 118 | Note that,
|
---|
| 119 | while truncating a file causes space on disk to be freed,
|
---|
| 120 | extending a file does not cause space to be allocated.
|
---|
| 121 | To extend a file and actually allocate the space,
|
---|
| 122 | it is necessary to explicitly write data to it,
|
---|
| 123 | using (for example) the shell's
|
---|
| 124 | .Ql >>
|
---|
| 125 | redirection syntax, or
|
---|
| 126 | .Xr dd 1 .
|
---|
| 127 | .SH EXIT STATUS
|
---|
| 128 | .Ex -std
|
---|
| 129 | If the operation fails for an argument,
|
---|
| 130 | truncate
|
---|
| 131 | will issue a diagnostic
|
---|
| 132 | and continue processing the remaining arguments.
|
---|
| 133 | .SH SEE ALSO
|
---|
| 134 | .BR dd(1),
|
---|
| 135 | .BR touch(1),
|
---|
| 136 | .BR truncate(2)
|
---|
| 137 | .SH STANDARDS
|
---|
| 138 | The
|
---|
| 139 | truncate
|
---|
| 140 | utility conforms to no known standards.
|
---|
| 141 | .SH HISTORY
|
---|
| 142 | The
|
---|
| 143 | truncate
|
---|
| 144 | utility first appeared in FreeBSD 4.2.
|
---|
| 145 | .SH AUTHORS
|
---|
| 146 | The truncate utility was written by Sheldon Hearn <sheldonh@starjuice.net>.
|
---|