truncate

Set length of file(s) (POSIX, toybox)

Syntax:

truncate [-c] -s size file...

Runs on:

QNX OS

Options:

-c
Don't create file if it doesn't exist.
-s size
Set new size (with optional size prefix and suffix; see description below)
file
The pathname of a file to use as input.

Description:

The truncate utility sets the length of one or more files, extending sparsely if necessary. The -s option comes with optional size prefixes and suffixes, listed below:

Size Prefixes

  • + — add
  • - — subtract
  • < — shrink to
  • > — expand to
  • / — multiple rounding down
  • % — multiple rounding up

Size Suffixes

  • k = 1024 bytes
  • m = 1024^2 bytes
  • g = 1024^3 bytes
  • t = 1024^4 bytes
  • p = 1024^5 bytes
  • e = 1024^6 bytes

This utility is provided as part of the toybox package. For information on how to enable it, see toybox.

Contributing author:

Rob Landley and the toybox project (see https://landley.net/toybox/).

Page updated: