Linux Text and File Operations Cheat Sheet/Empty a file without deleting it

Reset file length to zero bytes.

Section: Create, touch, truncate

Empty a file without deleting it

bash
bash
truncate -s 0 app.log

Learn the surrounding workflow

Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.

Related commands

Same sheet · prioritizing Create, touch, truncate
Create empty file or update timestamp
Touch a file path.
OpenIn sheetbashsame section
Write output to file and stdout
Save command output while still printing it.
OpenIn sheetbashsame section
Follow appended log lines
Watch file growth in real time.
OpenIn sheetbash1 tag match
Print file content
Output a file to standard output.
Show unified diff
Compare two files in patch-friendly format.
Split file into chunks
Split a large file into 100 MB parts.