Quoting thread:
[Roy]
I'm a beginner at shell scripting and I would like to borrow
someone's help. I wrote a little test script which I would like to
run nightly. /I cannot figure out how to erase files only if they are
void/. I searched the net to no avail and how to do this is beyond my
knowledge, I'm afraid.
[Adam]
By "void" do you mean empty? If so, this should work:
find -size 0 -exec rm '{}' ';'
*However* you might also want to filter out symlinks and special files
by doing this:
find -size 0 -type f -exec rm '{}' ';'
Test this sort of thing very carefully before deploying it, especially
in a script.
The -exec option bypasses aliases, so that "rm" is the real thing, not
"rm -i" if you have it aliased to that.
HTH.
[Simon]
By void, do you mean empty ?
'man test' will help, as a hint, '-s file' tests if file exists and
has a size greater than zero.
Thank you very much. I have combined your suggestions to create a script that
not only erases the empty files (Adam), but also generates an index file which
points to changes (Simon).
I also stripped that -erobots=off which I only included /by mistake/. The
scripts actually save bandwidth (no images) so they are benevolent,
unlike what
they may seem.
Roy
|