![]() |
|
|
|
|
|||||||
| 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 |
| listing folders and using in script | truCido | Shell Programming and Scripting | 1 | 05-31-2007 04:11 AM |
| script to loop around folders | grinder182533 | Shell Programming and Scripting | 2 | 11-14-2006 04:46 AM |
| Php script that copies Unix folders? | edtech | Shell Programming and Scripting | 4 | 09-26-2006 03:58 PM |
| Script to Find Diff from two folders | gkrishnag | UNIX for Advanced & Expert Users | 2 | 07-31-2006 10:14 PM |
| script to archive certain folders in a hierarchy | medazinol | Shell Programming and Scripting | 3 | 04-28-2005 07:45 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
|||
|
Script To dlete PDF file s and Folders
Hi
We have to delete PDF files and Folders older than five days .Can anyone help with the shell script Regards Ved |
| Forum Sponsor | ||
|
|
|
|||
|
Quote:
Code:
find <directory> -name "*.[pPdDfF]" -ctime +5 -exec rm {} \;
|
|
|||
|
Quote:
But i am new to shell scripting.How do you give the path here.I mean can you please help me with complete script. Regards |
|
|||
|
Hi guys
even though i am new i tried to put like this Is this correct #!/bin/sh echo "Removing tmp directories and PDF files older than 5 days created by users" #!/bin/sh cd /opt/dctm/....Path echo 'Current Direcotory is' $PWD "find ./ -name '*.pdf' -mtime +5 >>test.out" find ./ -type d -mtime +5 -exec rm -R {} \; find ./ -name '*.pdf' -exec rm '{}' ';' "find ./ -name '*.pdf' -mtime +5 >>test1.out" diff test.out,test1.out >> test2.out mailx -s" Deleted Files For $TODAY at $TIME" xyz.com <test2.out I am trying to delete folders and pdf files in temp and trying to write before and after and comparing to get deleted files and mailing them. |
|
||||
|
Code:
find ./ -name '*.pdf' -exec rm {} \;
"find ./ -name '*.pdf' -mtime +5 >>test1.out"
btw, i suggest you keep to the same programming style throughout your script --- makes it easier to debug that way ... and don't put your command line in double quotes as the shell will most likely not run it ... Code:
find ./ -type d -mtime +5 -exec rm -R {} \;
find ./ -name '*.pdf' -exec rm '{}' ';'
find ./ -name '*.pdf' -mtime +5 >>test1.out
|
||||
| Google The UNIX and Linux Forums |