The answer to your IT questions
 

Advanced search  • Search tips
My QUESTIONS & ANSWERS
 Question:

How to delete file content in linux

User Asked by: milen
Published on: 12:11/24.07.2008
Status: OPEN
How can I delete file content without opening the file? Is there such command in Unix/Linux?
I want to delete the content of some log files.
 Answers: 2
Sort by: /\ date | rating
Image Answer by: kuku
Posted on: 12:09/24.07.2008
Rating: No votes so far
If you want to delete the contents of a file without removing and recreating it you can try:

echo "" >  /some/path/to/logfile.log



Vote:

Image Answer by: xpert
Posted on: 12:11/24.07.2008
Rating: No votes so far
If you want to truncate a log file that is in use(process writes to it) by a running process without stopping the process then all that you need is the following shell command to clear out the active log file:


cat /dev/null > some_log_file.log

Vote:

Please vote! Your opinion matters!
If you haven't found what you've looking for, post a question
  
| Home | Hall of fame | Register | Log in | Terms of service | Help | Contacts |