FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > Redhat > Fedora User

 
 
LinkBack Thread Tools
 
Old 04-02-2008, 02:05 PM
"Dan Track"
 
Default : Ho wto find files created on a specific date

Hi

I need to delete files in my /opt/html/ directory that were
created/modified ON the 20th of March this year? Is there a way for me
to do this?

Thanks
Dan

--
fedora-list mailing list
fedora-list@redhat.com
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list
 
Old 04-02-2008, 02:07 PM
Keiran Smith
 
Default : Ho wto find files created on a specific date

Dan Track wrote:

Hi

I need to delete files in my /opt/html/ directory that were
created/modified ON the 20th of March this year? Is there a way for me
to do this?

Thanks
Dan



Hey Dan,

You could simply become root

su -

and do the following

rm -rf /opt/html/<file>

a wildcard can also be used

Cheers,

Keiran

--
fedora-list mailing list
fedora-list@redhat.com
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list
 
Old 04-02-2008, 02:14 PM
"Dan Track"
 
Default : Ho wto find files created on a specific date

Hi,

I don't think that's possible as there are literally hundreds of
various directories and thousands of files, each with their own
creation/modification date. Any other thoughts?

Thanks
Dan

On Wed, Apr 2, 2008 at 3:07 PM, Keiran Smith <ksmith@xcalibre.co.uk> wrote:
>
> Dan Track wrote:
>
> > Hi
> >
> > I need to delete files in my /opt/html/ directory that were
> > created/modified ON the 20th of March this year? Is there a way for me
> > to do this?
> >
> > Thanks
> > Dan
> >
> >
> >
> Hey Dan,
>
> You could simply become root
>
> su -
>
> and do the following
>
> rm -rf /opt/html/<file>
>
> a wildcard can also be used
>
> Cheers,
>
> Keiran
>
> --
> fedora-list mailing list
> fedora-list@redhat.com
> To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list
>

--
fedora-list mailing list
fedora-list@redhat.com
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list
 
Old 04-02-2008, 02:15 PM
Keiran Smith
 
Default : Ho wto find files created on a specific date

Dan Track wrote:

Hi,

I don't think that's possible as there are literally hundreds of
various directories and thousands of files, each with their own
creation/modification date. Any other thoughts?

Thanks
Dan

On Wed, Apr 2, 2008 at 3:07 PM, Keiran Smith <ksmith@xcalibre.co.uk> wrote:


Dan Track wrote:



Hi

I need to delete files in my /opt/html/ directory that were
created/modified ON the 20th of March this year? Is there a way for me
to do this?

Thanks
Dan





Hey Dan,

You could simply become root

su -

and do the following

rm -rf /opt/html/<file>

a wildcard can also be used

Cheers,

Keiran

--
fedora-list mailing list
fedora-list@redhat.com
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list






Hey Dan,

You could use a wild card so

rm -rf /opt/html/*

Would empty the directory

--
fedora-list mailing list
fedora-list@redhat.com
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list
 
Old 04-02-2008, 02:19 PM
"Mark Haney"
 
Default : Ho wto find files created on a specific date

Dan Track wrote:

Hi

I need to delete files in my /opt/html/ directory that were
created/modified ON the 20th of March this year? Is there a way for me
to do this?

Thanks
Dan



man find

The find command will do all you need it to do. Tons of options for
searching for files based on access/modify/creation times. I've never
tried the 'exec' part of find, I usually just pipe the output to
whatever else I might need (and in this case you can pipe if to rm with
arguments.



--
Libenter homines id quod volunt credunt -- Caius Julius Caesar


Mark Haney
Sr. Systems Administrator
ERC Broadband
(828) 350-2415

Call (866) ERC-7110 for after hours support

--
fedora-list mailing list
fedora-list@redhat.com
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list
 
Old 04-02-2008, 02:40 PM
Todd Denniston
 
Default : Ho wto find files created on a specific date

Dan Track wrote, On 04/02/2008 10:05 AM:

Hi

I need to delete files in my /opt/html/ directory that were
created/modified ON the 20th of March this year? Is there a way for me
to do this?

Thanks
Dan



an approximation, i.e., no guaranties, use at your own risk.
A few assumptions:
A) no files created/modified on the twentieth have been modified or touched
since then.
B) nothing changed any of the time stamps on the files created/modified on the
20th, i.e., no tar -x commands were used in /opt/html.



cd /tmp
touch --date="March 20" test20
touch --date="March 21" test21
find /opt/html/ -type f -newer test20 > list1
find /opt/html/ -type f -newer test21 > list2
diff -u list2 list1 |grep -e "^+/"
diff -u list2 list1 |grep -e "^-/"
now process one of those lists (I think the + list) and beware of spaces.
I would `ls -l --full` some of the files from the lists to figure out which one.

--
Todd Denniston
Crane Division, Naval Surface Warfare Center (NSWC Crane)
Harnessing the Power of Technology for the Warfighter

--
fedora-list mailing list
fedora-list@redhat.com
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list
 
Old 04-02-2008, 02:40 PM
Craig White
 
Default : Ho wto find files created on a specific date

On Wed, 2008-04-02 at 15:05 +0100, Dan Track wrote:
> Hi
>
> I need to delete files in my /opt/html/ directory that were
> created/modified ON the 20th of March this year? Is there a way for me
> to do this?
----
first - make a backup of the entire directory because this type of thing
is destructive and there is no 'undo' option

Then you should probably be aware of the man page for find which has
some examples that does things similar to this but you will want to test
the 'find' command before you add the part to 'rm'

The next problem is that the 'created' time isn't retained but the
modified time is...

find /opt/html -mtime +12

sounds about right to me...this should give you all files modified since
March 20th...

then you could output this to file...
find /opt/html -mtime +12 > /tmp/modified-since-march-20.txt
then if you wanted to exclude stuff modified since march-21st (so as not
to delete them)
find /opt/html -mtime +11 > /tmp/modified-since-march-21.txt

then you could 'diff' the difference to get a file list of those for
March 12th

Here's an example...
# find . -ctime +5 > /tmp/files1.txt
# find . -ctime +1 > /tmp/files2.txt
# diff /tmp/files1.txt /tmp/files2.txt

and then to clean up the diff, I add some other things...
# diff /tmp/files1.txt /tmp/files2.txt |grep '/' | sed 's/> //g'

and if I output this to a file, I could use that for deleting
purposes...

# diff /tmp/files1.txt /tmp/files2.txt |grep '/' | sed 's/> //g'
> /tmp/file-deletion-list.txt

and finally, my command to delete...

for file in `cat /tmp/file-deletion-list.txt`; do rm $file; done
# note, those are backticks and not single quotes

Mostly though, adjust as you go along and test this as your mileage will
definitely vary.

Craig

--
fedora-list mailing list
fedora-list@redhat.com
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list
 
Old 04-02-2008, 02:49 PM
Craig White
 
Default : Ho wto find files created on a specific date

On Wed, 2008-04-02 at 10:40 -0400, Todd Denniston wrote:

> cd /tmp
> touch --date="March 20" test20
> touch --date="March 21" test21
> find /opt/html/ -type f -newer test20 > list1
> find /opt/html/ -type f -newer test21 > list2
----
nice...this is very elegant

I need to file this away somewhere that I actually have a chance to find
this when I need it.

Thanks

Craig

--
fedora-list mailing list
fedora-list@redhat.com
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list
 
Old 04-02-2008, 03:01 PM
Todd Denniston
 
Default : Ho wto find files created on a specific date

Craig White wrote, On 04/02/2008 10:49 AM:

On Wed, 2008-04-02 at 10:40 -0400, Todd Denniston wrote:


cd /tmp
touch --date="March 20" test20
touch --date="March 21" test21
find /opt/html/ -type f -newer test20 > list1
find /opt/html/ -type f -newer test21 > list2

----
nice...this is very elegant

I need to file this away somewhere that I actually have a chance to find
this when I need it.

Thanks

Craig



and after seeing Mr. Haney's message I looked at the find man page a bit...

find /opt/html/ -type f -newer test20 -not -newer test21

same list as I got from the diff |grep, but without the need to sed, and it
_probably_ could be carefully combined with the -exec option of find to do the rm.


Open Source Scripting on the Fedora list.

--
Todd Denniston
Crane Division, Naval Surface Warfare Center (NSWC Crane)
Harnessing the Power of Technology for the Warfighter

--
fedora-list mailing list
fedora-list@redhat.com
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list
 
Old 04-02-2008, 03:03 PM
"Patrick O'Callaghan"
 
Default : Ho wto find files created on a specific date

On Wed, 2008-04-02 at 07:49 -0700, Craig White wrote:
> On Wed, 2008-04-02 at 10:40 -0400, Todd Denniston wrote:
>
> > cd /tmp
> > touch --date="March 20" test20
> > touch --date="March 21" test21
> > find /opt/html/ -type f -newer test20 > list1
> > find /opt/html/ -type f -newer test21 > list2
> ----
> nice...this is very elegant
>
> I need to file this away somewhere that I actually have a chance to find
> this when I need it.
>
> Thanks
>
> Craig

Alternatively:

find /opt/html -daystart -type f -ctime N -print0|xargs --null rm -f

where N is the number of days since the required date (starting with 1 =
yesterday).

Test with 'ls -lc' instead of 'rm' of course :-)

poc

--
fedora-list mailing list
fedora-list@redhat.com
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list
 

Thread Tools




All times are GMT. The time now is 01:02 PM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org