How Do I Truncate a File in Linux?
Contents

How do I truncate a text file in Linux?

To truncate a file in Linux use the redirection operator > followed by the file name.

What is truncate command in Linux?

The Linux truncate command is often used to shrink or extend the size of each FILE to the specified size. … If a FILE (for example archive or log files) is larger than the specified size, the extra data is lost, but if a FILE is shorter, it is extended and the extended part (hole) reads as zero bytes.

David Miller

David Miller

Executive Financial & Market Analyst

David Miller brings 15 years of experience in global economics, personal finance strategy, and market dynamics. He specializes in turning complex economic trends into actionable insights for everyday readers.

Share this article
Twitter Facebook Pinterest