Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 12 Jul 2001 11:28:56 -0700 (PDT)
From:      Philip Hallstrom <philip@adhesivemedia.com>
To:        David Hill <david@phobia.ms>
Cc:        <so@server.i-clue.de>, <gardhy@usvisanews.com>, <freebsd-questions@FreeBSD.ORG>
Subject:   Re: File Management...
Message-ID:  <20010712112710.U77691-100000@oddjob.adhesivemedia.com>
In-Reply-To: <20010712140222.6b5f1ca7.david@phobia.ms>

next in thread | previous in thread | raw e-mail | index | archive | help
> > > Hello Everyone,
> > >
> > > Would anyone know how to delete files based on the date modified
> > > timestamp of files?
> >
> > find /your/path/to/clean/up -date 3 -rm
> >
> > man find is your friend.
> >
> both -date and -rm are not options
>
> Try this example
>
> find /path -name *.txt -mtime argument | xargs rm -f

You might want to do it like this:

find /path -name *.txt -mtime argument -print0 | xargs -0 /bin/rm

The -print0 -0 stuff will use \0 as a deliminator rather than a space so
that if you have a file named "some text file.txt" it will get passed to
xargs correctly...

And using /bin/rm will ensure that you really are using the rm you want
to.

And of course it's always a really good idea to just print out the results
of the find before removing them :)

-philip



To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20010712112710.U77691-100000>