Re: A handy utility (at least for me)



On Mon, Aug 28, 2006 at 06:18:58PM +0200, Oliver Fromme wrote:
Rick C. Petty wrote:
>
> I find that the following command works just fine for me:
>
> find /usr/ports -type d -name work -prune -print -delete

The following is probably the most efficient solution.
It doesn't run into all subdirectories (and works with
an arbitrary numebr of subdirectories).

cd /usr/ports; echo */*/work | xargs rm -rf

You might as well just do:

rm -rf /usr/ports/*/*/work

because using xargs doesn't gain you anything in this case. How does your
example work with an arbitrary number of subdirectories?

Your example does't work if the number of work directories exceeds the
maximum number of arguments (4096 IIRC), which can happen amidst 16,000
ports. This bit me once so I use find now (granted this was before I was
using portupgrade).

Also I don't see how your example is any more efficient than find-- you're
just making the shell do the work instead of find. In either case, it's
just a sequence of opendir()/readdir(). In fact your example would start
secondary processes to do the directory removal; find has this built in
and thus doesn't have the overhead of process forking. Perhaps if on an
arbitrary directory tree, find may not be as efficient, but the only
directories deeper than depth of two (in my example) are work directories,
and they would be pruned.

-- Rick C. Petty
_______________________________________________
freebsd-hackers@xxxxxxxxxxx mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "freebsd-hackers-unsubscribe@xxxxxxxxxxx"



Relevant Pages

  • Re: How to find total MB of a directory plus all subdirectories
    ... Nigel Henry wrote: ... named Sounds Library, this contains many subdirectories, which contain ... What command can I use to find out the disk space this directory is ... subdirectories are multi worded without any hyphens, ...
    (Fedora)
  • Re: Need some small help on shell script - delete old files
    ... command so that it does not search subdirectories past this directory ... Please look at my original script from the first message to this ... # this is sufficiently unique in the BKPPATH ... The find command shows all files in the directory and subdirectories. ...
    (comp.unix.shell)
  • Re: Need some small help on shell script - delete old files
    ... command so that it does not search subdirectories past this directory ... The find command shows all files in the directory and subdirectories. ... gzip of $FILENAME at the end is not necessary as far as I can tell ... I am running the script and have noticed that the file names have been ...
    (comp.unix.shell)
  • Re: Need some small help on shell script - delete old files
    ... command so that it does not search subdirectories past this directory ... The find command shows all files in the directory and subdirectories. ... I am using your script. ... recent dump is always left un-compressed with no .gz extension. ...
    (comp.unix.shell)
  • Re: How to delete directory someone created in my directory
    ... I also cannot change the protections of the directory. ... This command has been superseded by the SET SECURITY/PROTECTION ... This may generate errors if it tries to delete non-empty subdirectories. ... See Help Backup /BY_OWNER to learn about setting the owner of ...
    (comp.os.vms)