home | list info | list archive | date index | thread index

Re: help with find

> I want to check al the file sizes before I delete things
> because I am paranoid

Never be afraid to do something in 2 or 3 steps even if it can be done
in 1.  Especially when working in mission critical production systems.

In situations like this when I'm programmatically removing a bunch of
files I often write a script that does nothing but write another
script.   Then I review the 2nd script and execute it.  The point of
the 2nd script is that it removes all the logic and loops and decision
points from the first script - it becomes extremely straightforward.
And sure that means sometimes it is not trivial to review because it
could be thousands of lines long.

In your case even though you can do it all with one find command you
might consider using a find command to create a list of files (taking
into account the possibility of spaces) and then writing a simple BASH
script with a loop to read each file from the list, check whether it
is zero sized, then remove it.  That also gives you essentially "2
sets of eyes" on the files before removing them.  The "find" command
has already identified them as being zero size, and if you do that
again in a BASH script that is a completely different program with a
completely different code base making that decision afresh with a 2nd
set of eyes.

To unsubscribe send a blank message to linux+unsubscribe [ at ] linux-ottawa [ dot ] org
To get help send a blank message to linux+help [ at ] linux-ottawa [ dot ] org
To visit the archives: https://lists.linux-ottawa.org

references

message navigation