How to Truncate a File

104 62
    • 1). Access the Linux shell by navigating to the "System Tools" menu and selecting the the program used to launch the shell. The program used to launch the shell is usually called the "Terminal."

    • 2). Copy the following code into the shell:

      truncate -s 0 {filename.txt}

      ls -lh filename.txt

      truncate -s 0 filename.txt

      ls -lh filename.txt

    • 3). Modify the code so that every reference to "filename.txt" is the name of the actual file that will be truncated.

    • 4). Replace instances of "0" in the code with the size figure to which the desired file will be set.

    • 5). Press the "Enter" key to truncate the desired file. Repeat the process to truncate multiple files.

Subscribe to our newsletter
Sign up here to get the latest news, updates and special offers delivered directly to your inbox.
You can unsubscribe at any time

Leave A Reply

Your email address will not be published.