![]() |
|
|
|
|
|||||||
| 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 |
| deleting files based on file name and modified time | ammu | UNIX for Dummies Questions & Answers | 1 | 01-22-2008 08:09 AM |
| Traversing thru dirs and deleting files based on date | ravi2082 | Shell Programming and Scripting | 5 | 07-18-2007 01:28 PM |
| Read file based on condition | sbasetty | Shell Programming and Scripting | 5 | 01-31-2007 11:54 PM |
| Deleting files with zero length using ls command | GNMIKE | UNIX for Dummies Questions & Answers | 6 | 07-10-2005 04:34 AM |
| Deleting files automatically, the condition in the month of creation | FabioALex | UNIX for Dummies Questions & Answers | 4 | 12-10-2001 05:14 PM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
command for deleting log files based on some condition
Hello,
Can anyone pls. provide me with the command for deleting files older then 15 days with a restriction to keep at least 5 files in a directory even if they are older then 15 days. Any help will be highly appreciated. Thanks, Pulkit |
| Forum Sponsor | ||
|
|
|
#2
|
|||
|
|||
|
What is the reason to this on your system, or is it homework?
Regards |
|
#3
|
|||
|
|||
|
Yes its a kind of assignment...
|
|
#4
|
|||
|
|||
|
Ok, some hints:
To find older files you can use the find command with the -mtime option. To keep 5 files of the selection you can pipe the result to awk, to ignore the first 5 files you can do something like: Code:
awk 'NR<6{next}{print}'
Code:
find <options> | awk '....' | rm -f Code:
...| xargs rm -f Regards |
|
#5
|
|||
|
|||
|
Thanks in Tons...
|
|||
| Google The UNIX and Linux Forums |