5 Ways to Empty or Delete a Large File Content in Linux

Best Affordable Linux and WordPress Services For Your Business
Outsource Your Linux and WordPress Project and Get it Promptly Completed Remotely and Delivered Online.

If You Appreciate What We Do Here On TecMint, You Should Consider:

  1. Stay Connected to: Twitter | Facebook | Google Plus
  2. Subscribe to our email updates: Sign Up Now
  3. Get your own self-hosted blog with a Free Domain at ($3.45/month).
  4. Become a Supporter - Make a contribution via PayPal
  5. Support us by purchasing our premium books in PDF format.
  6. Support us by taking our online Linux courses

We are thankful for your never ending support.

Aaron Kili

Aaron Kili is a Linux and F.O.S.S enthusiast, an upcoming Linux SysAdmin, web developer, and currently a content creator for TecMint who loves working with computers and strongly believes in sharing knowledge.

Your name can also be listed here. Got a tip? Submit it here to become an TecMint author.

RedHat RHCE and RHCSA Certification Book
Linux Foundation LFCS and LFCE Certification Preparation Guide

You may also like...

9 Responses

  1. lokiyo says:

    I know > and :> are methods that empty the file without actually “touching” it, if the file is being used.

    Are the other methods working the same way? We always get tickets for large files and 80% of the time, we need to compress the contents of the file and truncate or “zero” it but with the problem that the file is being used and we can’t stop the process using it.

    At the moment, I only used the redirect methods I mentioned at the start of my post.

    • Ravi Saive says:


      All know that > and :> are standard options to empty the large file content without being touching it. But there are other methods works same way as show in this article, I think you should give a try and see..

  2. James Merrill says:

    When I opened this link I was expecting ways to actually get rid of the file contents on the disk. All of these methods only unlink the disk space from the file, leaving the contents on the drive.
    Of the choices listed, though, I think “truncate -s 0 ” is the best option.

  3. Mike says:

    Another simple option utilizing the cat command:
    cat > /path/to/file
    Then hit Ctrl+D
    Voila, empty file.

  4. Bruno DARCET says:

    every trick using redirection “>” are the same !

    : >file
    true >file
    cat /dev/null >file
    my_prog >file (if my_prog produce no output)

    because the shell truncate (or create) “file” before launching the command (cat, true, …), the most important is that the command produces no output !!!

    you can understand that >file is the best one because it needs no other program !

    • Aaron Kili says:


      It is true, the basic idea is the use of the redirection mechanism. We are simply offering various alternatives that a user can choose to use, though they are more like the same.

Leave a Reply to James Merrill Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.