in Advanced 

Question preview

HomeQuestion preview:
Log in

How to delete file content in linux

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.
Do you know someone who could answer? Ask him for help
Answers: 2
Sort by: date rating
image kuku
15:09/24.07.2008
1 from possible 5 with 1 votes
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 xpert
15:11/24.07.2008
-
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
Ask question
| Home | Hall of fame | Registration | Log in | Terms of service | Privacy policy | Help | Contacts | RSS |