How Do You Clear a Text File in Linux?
Contents How Do I Empty a Text File in Linux? How to Remove Files to Delete a Single File, Use the Rm or Unlink Command Followed by the File Name: Unlink...
Contents
How do I empty a text file in Linux?
How to Remove Files
- To delete a single file, use the rm or unlink command followed by the file name: unlink filename rm filename. …
- To delete multiple files at once, use the rm command followed by the file names separated by space. …
- Use the rm with the -i option to confirm each file before deleting it: rm -i filename(s)
1 сент. 2019 г.
Must Read
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()