Changeset View
Changeset View
Standalone View
Standalone View
head/usr.bin/truncate/truncate.1
Show All 19 Lines | |||||
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||||
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||||
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||||
.\" SUCH DAMAGE. | .\" SUCH DAMAGE. | ||||
.\" | .\" | ||||
.\" $FreeBSD$ | .\" $FreeBSD$ | ||||
.\" | .\" | ||||
.Dd December 19, 2006 | .Dd July 27, 2020 | ||||
.Dt TRUNCATE 1 | .Dt TRUNCATE 1 | ||||
.Os | .Os | ||||
.Sh NAME | .Sh NAME | ||||
.Nm truncate | .Nm truncate | ||||
.Nd truncate or extend the length of files | .Nd truncate or extend the length of files | ||||
.Sh SYNOPSIS | .Sh SYNOPSIS | ||||
.Nm | .Nm | ||||
.Op Fl c | .Op Fl c | ||||
▲ Show 20 Lines • Show All 101 Lines • ▼ Show 20 Lines | |||||
redirection syntax, or | redirection syntax, or | ||||
.Xr dd 1 . | .Xr dd 1 . | ||||
.Sh EXIT STATUS | .Sh EXIT STATUS | ||||
.Ex -std | .Ex -std | ||||
If the operation fails for an argument, | If the operation fails for an argument, | ||||
.Nm | .Nm | ||||
will issue a diagnostic | will issue a diagnostic | ||||
and continue processing the remaining arguments. | 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 | .Sh SEE ALSO | ||||
.Xr dd 1 , | .Xr dd 1 , | ||||
.Xr touch 1 , | .Xr touch 1 , | ||||
.Xr truncate 2 | .Xr truncate 2 | ||||
.Sh STANDARDS | .Sh STANDARDS | ||||
The | The | ||||
.Nm | .Nm | ||||
utility conforms to no known standards. | utility conforms to no known standards. | ||||
Show All 10 Lines |