How Do I Empty a Text File in Linux?
Contents How Do I Delete a Text File? Use File. Truncate() to Erase the File Contents of a Text File File = Open(“Sample. Txt”, ”R+”) File. Truncate(0) File...
Contents
How do I delete a text file?
Use file. truncate() to erase the file contents of a text file
- file = open(“sample.txt”,”r+”)
- file. truncate(0)
- file. close()
How do you delete all empty files in Linux?
The syntax is as follows to find and delete all empty directories using BSD or GNU find command:
- find /path/to/dir -empty -type d -delete.
- find /path/to/dir -empty -type f -delete.
- find ~/Downloads/ -empty -type d -delete.
- find ~/Downloads/ -empty -type -f -delete.
11 сент. 2015 г.