visitor (0 QPoints)
  • FR
  • EN
  • NL
  • DE
  • ES
262 experts, 1140 registered users, 1616 questions already answered
European Experts Exchange, the very best site for high-quality IT solutions

We now celebrate our 5 years of existence and break our frequentation records... Here are the stats of those 5 years.

Operating Systems :: Unix :: deleting files


By: roe1and Great Britain  Date: 23/04/2008 12:17:00  English  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 English  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

 Add This Article To:
 del.icio.usDel.icio.us  diggDigg  googleGoogle  spurlSpurl
 blinkBlink  wongWong  simpySimpy  yahooY! MyWeb 
EContact
browser fav
page generated in 4752.521040 milliseconds

Why Google AdSense ads ?

compteur
 Ranking-Hits PageRank for this page