truncate
truncate [OPCIÓN]... [ARCHIVO]...
Reducir o extender el tamaño de cada archivo al tamaño especificado.
Options
--io-blocks,-o-
tratar TAMAÑO como el número de bloques de E/S del archivo en lugar de bytes (NO IMPLEMENTADO)
--no-create,-c-
no crear archivos que no existen
--reference=<RFILE>,-r <RFILE>-
basar el tamaño de cada archivo en el tamaño de RARCHIVO
--size=<SIZE>,-s <SIZE>-
establecer o ajustar el tamaño de cada archivo según TAMAÑO, que está en bytes a menos que se especifique –io-blocks
TAMAÑO es un entero con un prefijo opcional y unidad opcional. Las unidades disponibles (K, M, G, T, P, E, Z, e Y) usan el siguiente formato: ‘KB’ => 1000 (kilobytes) ‘K’ => 1024 (kibibytes) ‘MB’ => 10001000 (megabytes) ‘M’ => 10241024 (mebibytes) ‘GB’ => 100010001000 (gigabytes) ‘G’ => 102410241024 (gibibytes) TAMAÑO también puede tener uno de los siguientes prefijos para ajustar el tamaño de cada archivo basado en su tamaño actual: ‘+’ => extender por ‘-’ => reducir por ‘<’ => a lo más ‘>’ => al menos ‘/’ => redondear hacia abajo a múltiplo de ‘%’ => redondear hacia arriba a múltiplo de
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 under the CC BY 4.0 License.
Please note that, as uutils is a work in progress, some examples might fail.