Scroll to navigation

TRUNCATE(1) General Commands Manual TRUNCATE(1)

NAME

truncate - Shrink or extend the size of each file to the specified size.

SYNOPSIS

truncate [-o|--io-blocks] [-c|--no-create] [-r|--reference] [-s|--size] [-h|--help] [-V|--version] <FILE>

DESCRIPTION

Shrink or extend the size of each file to the specified size.

OPTIONS

treat SIZE as the number of I/O blocks of the file rather than bytes (NOT IMPLEMENTED)
do not create files that do not exist
base the size of each file on the size of RFILE
set or adjust the size of each file according to SIZE, which is in bytes unless --io-blocks is specified
Print help
Print version
<FILE>

EXTRA

SIZE is an integer with an optional prefix and optional unit. The available units (K, M, G, T, P, E, Z, and Y) use the following format:
'KB' => 1000 (kilobytes)
'K' => 1024 (kibibytes)
'MB' => 1000*1000 (megabytes)
'M' => 1024*1024 (mebibytes)
'GB' => 1000*1000*1000 (gigabytes)
'G' => 1024*1024*1024 (gibibytes) SIZE may also be prefixed by one of the following to adjust the size of each file based on its current size:
'+' => extend by
'-' => reduce by
'<' => at most
'>' => at least
'/' => round down to multiple of
'%' => round up to multiple of

VERSION

v(uutils coreutils) 0.8.0

EXAMPLES

Set a size of 10 GB to an existing file, or create a new file with the specified size:

truncate [-s|--size] 10G path/to/file

Extend the file size by 50 MiB, fill with holes (which reads as zero bytes):

truncate [-s|--size] +50M path/to/file

Shrink the file by 2 GiB, by removing data from the end of file:

truncate [-s|--size] -2G path/to/file

Empty the file's content:

truncate [-s|--size] 0 path/to/file

Empty the file's content, but do not create the file if it does not exist:

truncate [-s|--size] 0 [-c|--no-create] path/to/file

The examples are provided by the tldr-pages project <https://tldr.sh> under the CC BY 4.0 License. Please note that, as uutils is a work in progress, some examples might fail.

2026-05-17