[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: new 'rm' option

From: Bob Proulx
Subject: Re: new 'rm' option
Date: Thu, 25 Apr 2002 23:12:36 -0600

> I was interested in adding a -0 or -z option to rm so that it removes files
> of size zero. If you write a shell one-liner to do this enough times, it
> makes sense to add it to the utility.
> x.zero_size = 1 :)
> Has anyone thought about this idea? Is it feasible or practical?

What you are asking for is most comonly accomplished on unix systems
by combining smaller commands into more powerful combinations of
commands.  That is the unix philosophy.  Instead of creating huge
complex and bloated programs which never quite do what you want the
unix philosophy is to combine those smaller modular programs to
accomplish your task.

  find "$@" -size 0 -print0 | xargs -0 rm

Here is one example.  Find all files below the script arguments which
are of zero size and print them into the pipe to the xargs command
where it will execute rm upon each of them.

If this is something that you find yourself doing often, as you
suggest, then you should create a script such as the above and add it
to your bin directory.  At that time you will have easily created your
command.  Call it rm0 or some such and you can then 'rm0 /path/dir'


reply via email to

[Prev in Thread] Current Thread [Next in Thread]