xargs & awk are probably an option

eg : remove all files in current folder with timestamp of 16:15 (you might
want to try this with ls -l at the end instead of rm -f first off just to
make sure awk is pointing at the right field output from ls - if it lists
the files you expect then it should be correct)

ls -l | grep '16:15' | awk '{print $9}' | xargs rm -f

This will NOT neatly traverse directories though - if you are feeling brave
you could replace the -f at the end with a -rf to recurse

Above is offered with no liability implied or otherwise - it is just a bit
of advice which you should understand yourself before executing !

A better way would be a perl program that actually works on the datestamps
on the files themselves and walks through the directory structure
recursively in a controlled fashion, much safer as it can be test run &
clearly understood first

Martin


On 17 February 2011 15:42, Stuart Bird <e_tect...@yahoo.co.uk> wrote:

> Hi All
>
> I have inadvertently copied some files and directories into a system folder
> on a test server (apache). There is a lot of files and folders and I don't
> want to spend the time doing it manually if I can help it. The only way I
> can tell what to delete and what I want to keep is by sorting on the
> creation date aftr running:
>
> # ls -l | grep <creation_time>
>
> What I cant work out is how I can then "rm -R" just those files and
> folders, leaving the ones with the older creation times intact.
>
> Can anybody suggest a command that might work.
>
> Cheers
>
> Stu
>
>
> _______________________________________________
> Peterboro mailing list
> Peterboro@mailman.lug.org.uk
> https://mailman.lug.org.uk/mailman/listinfo/peterboro
>
_______________________________________________
Peterboro mailing list
Peterboro@mailman.lug.org.uk
https://mailman.lug.org.uk/mailman/listinfo/peterboro

Reply via email to