Skip to Content
gnux

-s, --size

Set or adjust the file size by SIZE bytes.

An option of truncatex.

Usage

truncatex -s SIZE OPTION... FILE...
truncatex --size=SIZE OPTION... FILE...

Details

ShortLongValueDefaultMeaning
-s--sizeSIZEset or adjust the file size by SIZE bytes

Examples

Empty a log file without deleting it

truncatex -s 0 app.log

Create a 100 MiB (sparse) file

truncatex -s 100M disk.img

Create a file of exactly one million bytes

truncatex -s 1MB data.bin

Grow a file by 1 KiB of zero bytes

truncatex -s +1K data.bin

Remove the last 10 bytes of a file

truncatex -s -10 data.bin

Cap a file at 1 MiB, leaving smaller files alone

truncatex -s '<1M' cache.db

Make sure a file is at least 4 KiB

truncatex -s '>4K' header.bin

Round a file's size up to a multiple of 512 bytes

truncatex -s %512 image.raw

Round a file's size down to a multiple of 4 KiB

truncatex -s /4K image.raw

Make a file 100 bytes larger than another

truncatex -r original.bin -s +100 copy.bin

Empty every log that exists, without creating missing ones

truncatex -c -s 0 a.log b.log c.log

Size a file in I/O blocks rather than bytes

truncatex -o -s 8 blocks.bin

Check the result with wcx

truncatex -s 2K f && wcx -c f

Help in the terminal

gnux help truncatex --size

On this page