Home Messages Index
[Date Prev][Date Next][Thread Prev][Thread Next]
Author IndexDate IndexThread Index

Re: [linux-users] Need Help with a Shell Script

  • To: linux-users@lists.man.ac.uk
  • Subject: Re: [linux-users] Need Help with a Shell Script
  • From: Roy Schestowitz <r@schestowitz.com>
  • Date: Mon, 20 Jun 2005 12:02:07 +0100
  • Cc: Adam Funk <adam.funk@manchester.ac.uk>, Simon Hobson <linux@thehobsons.co.uk>
  • Delivery-date: Mon, 20 Jun 2005 12:02:08 +0100
  • Envelope-to: s@schestowitz.com
  • In-reply-to: <200506200941.53361.adam.funk@manchester.ac.uk>
  • References: <20050619134346.xrznue8pdi68ws4g@banana.catalyst2.com> <200506200941.53361.adam.funk@manchester.ac.uk>
  • User-agent: Internet Messaging Program (IMP) H3 (4.0)
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


[Date Prev][Date Next][Thread Prev][Thread Next]
Author IndexDate IndexThread Index