Removal script

Michael Schuster michaelsprivate at gmail.com
Sat Feb 15 13:41:33 UTC 2020


I would suggest

find /mysources - type d -name nonsense ...

HTH
Michael

On Sat, Feb 15, 2020, 14:36 Karl Denninger <karl at denninger.net> wrote:

>
> On 2/15/2020 07:31, Jos Chrispijn wrote:
> > I am looking for a way to remove a nested subdirectory in a directory.
> >
> > Example:
> > directory /mysources has a certain number of subdirectories which
> > contain subdirectory 'nonsense' in various subdirectories, which
> > contain also subdirectory 'nonsense', etc.
> >
> > What I would like to do is that the script removes all 'nonsense'
> > folders in the base /mysources.
> > Can you pls tell me how I can do that savest? Thanks!
> >
> > /jos
>
> Well, there's no completely "safe" way that might not nuke something you
> don't intend, but....
>
> find . -type d -name 'nonsense' -exec rm -rf {} \;
>
> Starts in the current directory, walks the tree, anything that is a
> directory and has the name "nonsense" is "rm -rf'd".
>
> Just don't be wrong about any of those directories being or having in
> them something you don't want nuked.  "rm -rf" does exactly what you
> tell it to and it's entirely possible to really hose yourself with it
> (e.g. "rm -rf /" will do exactly what you think it might.)
>
> --
> Karl Denninger
> karl at denninger.net <mailto:karl at denninger.net>
> /The Market Ticker/
> /[S/MIME encrypted email preferred]/
>


More information about the freebsd-questions mailing list