![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| how to delete content in a file (delete content only) | kittusri9 | Shell Programming and Scripting | 5 | 05-15-2008 10:12 AM |
| how to archive logs older than 5 days & then delete them? | timus1980 | UNIX for Advanced & Expert Users | 1 | 02-08-2008 02:53 AM |
| Script to delete logs or take backups under specific user | namishtiwari | Shell Programming and Scripting | 12 | 01-25-2008 02:31 AM |
| Delete logs every 3 hours | tungaw2004 | UNIX for Dummies Questions & Answers | 3 | 12-09-2007 04:22 AM |
| Delete old logs | chiru_h | Shell Programming and Scripting | 4 | 09-14-2007 03:33 PM |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
|||
|
I need to delete the content out of a number of logs
I'm just starting out in scripting (taking online classes) but I need to know how to clean out (delete) the content of a number of logs. All of the files end in 'trc'. Does anyone have a script or command (SED or AWK) I can use?
Julie |
| Forum Sponsor | ||
|
|
|
|||
|
Thanks for the reply. (This is a work question). I need to remove the content of multiple logs within a directory but not the log itself. Processes are conected and if I remove the logs I have Inode issues. So, I was hoping to find a script or command that would allow me to use a wildcard and would remove the content of the logs.
Thanks Julie |
|
|||
|
A point to be careful of here.
Simply removing entries from a log file or removing a log file whilst its logging process is still running might not release disk space. You may have to stop and restart the logging process (whatever that process is) before the disk space is available for other uses and other processes.
__________________
Senior Analyst/Programmer |
|
||||
|
If you want the remove the contents of the logs without removing the file itself then echo a blank to the log, but dont append to the log, overwrite the log instead. This will overwrite all contents of the log with a blank space. The result is an empty log.
for $LOG in ` ls -1 /log-path/*.trc` do echo "" > $LOG done Last edited by google; 09-30-2003 at 07:06 AM. |
||||
| Google The UNIX and Linux Forums |