0

how to clear only the contents in file

Till now i will remove the file & recreate it. is it possible to clear only the contents instead of removing the whole file.....???

Advanced commands Add a comment
wyatt
asked Feb 07 2017

Answer

0

Yes, truncate command could be used.

For example:

The file called test is created with some contents, and the below command will remove only the contents but not the file...

# truncate -s 0 [test]
Add a comment
jagannatharumugam
asked Feb 10 2017
edited Oct 05 2018
Post your Answer