How to Truncate a File
- 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.