Languages

Linux - how to empty the file from command line?

13 points
Asked by:
Kate_C
2854

How to remove the content of a file under linux from command line level?
I do not want to remove the entire file and create new file.
I just want to clear the entire file to 0 bytes.
What is the best way to do it?

1 answers
1 points
Answered by:
Kate_C
2854

Run following command:

echo "" > /path/to/my/file

 

0 comments Add comment
Hey 👋
Would you like to know what we do?
  • Dirask is a friendly IT community for learners, professionals and hobbyists to share their knowledge and help each other in extraordinary easy way.
  • We welcome everyone,
    no matter what the experience,
    no matter how basic the question is,
    this community will help you.