TRUNCATE(1) General Commands Manual TRUNCATE(1)

truncatechange the size of files

truncate [-c] -r ref_file file...

truncate [-c] -s [+|-|%|/]size[suffix] file...

truncate changes the size of each given file. Either with a size operation given via the -s option or via a reference file given by -r ref_file.

Prevent creating new files.
ref_file
Set the size of file based on the file size of ref_file.
[+|-|%|/]size[suffix]
Size operation.
+
Extend file by size
-
Reduce file by size
%
Round up file into a multiple of size, useful for chunks.
/
Round down file into a multiple of size, useful for chunks.

size is an integer optionally followed by a suffix being one of KMGTP (Kilo, Mega, Giga, Tera, ...) using power of 1024 by default, which can be either explicit via adding iB (like MiB), or turned into powers of 1000 by adding B (like MB).

The truncate utility exits 0 on success, and >0 if an error occurs.

split(1)

A truncate utility appeared in FreeBSD 4.2.

Haelwenn (lanodan) Monnier <contact+utils@hacktivis.me>

October 12, 2024 Linux