Languages
[Edit]
EN

Linux empty a file

2 points
Created by:
Teilsa
1315

Quick solution:

Practical example.

In below example we empty the tomcat logs.

Steps:

  • Before the file size is 636M
  • We executed the command to empty the file cp /dev/null catalina.out
  • After the file size is 0

Below we have an example from linux command line.

Before - file size 636M:

Execute command:

After - file size 0:

Other solutions

Edit

1. It is posible to redirect empty string into file.

2. dev-null redirection gives same result

1
Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.

Linux

Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join