I have been struggling to write a ruby script that can detect if a file
with a certain extension exists and to delete that file.
I have this:
total_size = 0
Find.find(ENV[“HOME”]) do |path|
if File.basename(path) == ?.
Find.prune # Don’t look any further into this directory.
total_size += FileTest.size(path)
total_size = total_size / 1024
print "Current home directory “,total_size / 1024, " MB\n”,
it checks the home dir and reports how much space it takes but i also
want to delete certain files. Is this possible? if so, can you give me
an example so i can work it out?