truncate -s 0 file.txt

Category: File Operations

truncate -s 0 file.txt

Truncate a file to zero bytes (empty it)

Empties a file instantly without deleting it — sets its size to zero bytes. The file still exists but is blank.
Looking for more? Search all 7,657 commands — works offline, in English or Spanish, and fixes typos.