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 г.