|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Removing Files
Code:
#!/usr/bin/ksh xfolder="/serv1/apache/public/data/results" find $xfolder -atime +0 | while read file do rm -f $file done exit hi...i'm trying to write a ksh to delete the files in /serv1/apache/public/data/results folder... but it says: Quote:
I'm not trying to remove the directory, I'm trying to remove the files in the results directory... any help would be great! thanks |
|
#2
|
|||
|
|||
|
This seems like the hard way to do it. Why not just use find?
Code:
#!/usr/bin/ksh
xfolder="/serv1/apache/public/data/results"
find $xfolder -atime +0 -exec rm -f {} \;
It basically does the same thing.
__________________
Need Java help? Want to help people who do? Sit down with a cup of Java at the hotjoe forums. |
|
#3
|
||||
|
||||
|
Have you tried just echoing the files found to insure your find command is picking up the correct data?
I ran this same script without the "rm -f" part on an AIX 5.2 server using ksh. Didn't have any problems. |
|
#4
|
||||
|
||||
|
I messed with the find command a bit more and noticed that it will include the search directory in your results if the directory fits the atime criteria.
You probably just need to limit your find command to just the files within the directory, i.e.: Code:
find /searchdir/ -type f -atime +0 -exec rm -f {} \;
|
|
#5
|
|||
|
|||
|
Code:
find /temp -atime +3 | grep tmp| while read file do rm -f $file done how about with grep commands, is there a way to simplify without doing a loop like above? |
![]() |
| Viewing: Dev Shed Forums > Operating Systems > UNIX Help > Removing Files |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|