NetBSD-Bugs archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
bin/60532: port truncate(1) from FreeBSD
>Number: 60532
>Category: bin
>Synopsis: port truncate(1) from FreeBSD
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: bin-bug-people
>State: open
>Class: change-request
>Submitter-Id: net
>Arrival-Date: Mon Aug 03 08:35:00 +0000 2026
>Originator: Ivan Shmakov
>Release: NetBSD 10.1
>Organization:
Dbus-free station.
>Environment:
Architecture: x86_64
Machine: amd64
>Description:
Please port truncate(1) [1] from FreeBSD:
> NAME
> truncate - resize files or manage file space
> SYNOPSIS
> truncate [-c] -s [+|-|%|/]size[SUFFIX] file ...
> truncate [-c] -r rfile file ...
> truncate [-c] -d [-o offset[SUFFIX]] -l length[SUFFIX] file ...
> DESCRIPTION
> The truncate utility adjusts the length of each regular file
> given on the command-line, or performs space management with
> the given offset and the length over a regular file given on
> the command-line.
[1] http://man.freebsd.org/cgi/man.cgi?query=truncate&sektion=1
truncate(1) allows for directly changing the size of a file,
including creating a sparse file. In place of the old trick of
using dd(1) to write a block at an offset of size minus one:
$ dd if=/dev/zero of=bigdisk.2048.udf seek=9999999 count=1
(From newfs_udf(8).) It becomes possible to create a sparse
file like:
$ truncate -s5000000K -- bigdisk.2048.udf
Also, I find it occasionally convenient when recovering after
adding arbitrary data to a file by accident; like, say:
$ date >> foo
$ truncate -s-29 -- foo
>How-To-Repeat:
>Fix:
Home |
Main Index |
Thread Index |
Old Index