Operating Systems :: Unix :: deleting files |
|||
| By: roe1and |
Date: 23/04/2008 12:17:00 |
Points: 20 | Status: Answered Quality : Excellent |
| i want to delete all the .old files in a directory and its subdirectories. the subdirectories are about 4 deep. i've tried rm -rf *.old but i think this only goes one deep? i could use a php or perl script but it seems to me that the unlink() function is extremely slow. any ideas? | |||
| By: VGR | Date: 23/04/2008 21:08:30 | Type : Answer |
|
| I think rm ha a "recursive search" switch, but I may be wrong. personally, I would do something like this : rm -f < find / -name *.old [s] where [s] is the proper find switch for recursive search. make sure find returns full pathes. Then pass the files list to rm -f as for unlink(), it's not as slow as you think. It should be mapped to the fastest OS dependent function. In your case, the destruction of the inode, or a "rm" using PHP, you're right, a recursive function with readdir() would do, or a de-recursified version with a maximum depth, say 5 in your case. All not that difficult. Come back again in case of errors or details needed. |
|||
|
Do register to be able to answer |
|||
©2010 These pages are served without commercial sponsorship. (No popup ads, etc...). Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE.
Please DO link to this page!








