mirror of
https://gitea.com/mcereda/oam.git
synced 2026-02-09 05:44:23 +00:00
1012 B
1012 B
The truncate command
Shrink or extend the size of a file to the specified size.
Table of contents
TL;DR
# Empty the contents of files.
truncate -s 0 'file'
# Set the size of an existing file.
# if the file does not exist, create it anew of the specified size.
truncate -s 100 'file'
truncate --size 5k 'file'
truncate --size 10G 'file'
# Extend a file's size by 50 MiB and fill it with holes.
# Holes read as zero bytes.
truncate --size +50M 'file'
# Shrink a file by 2 GiB.
# Removes data from the end of file.
truncate --size -2G 'file'
# Empty the file's content, but do not create it if existing.
truncate --no-create --size 0 'file'