aspose file tools*
The moose likes Linux / UNIX and the fly likes rm file on a specifc date Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » Linux / UNIX
Bookmark "rm file on a specifc date" Watch "rm file on a specifc date" New topic
Author

rm file on a specifc date

Muhammad Imad Qureshi
Ranch Hand

Joined: Sep 13, 2005
Posts: 238
Hi

I want to delete the results of following command

ls -lt | grep 'Aug 31'

I have already tried following

create a file

touch -t 200909010000 Sep01

and then run

find /da/prod/daprod/batch_ftp -newer Sep01 -exec ls -la {} \;

but this command returns nothing. I thought the above command will work and I'll simply replace ls by rm. This is a n AIX box. Can someone please help?

Thanks
Imad
Stefan Wagner
Ranch Hand

Joined: Jun 02, 2003
Posts: 1923

Aug 31 doesn't look newer than Sep 01 to me, or am I missing something?

Files older than one day might be specified by mtime:

Instead of rm you may use -delete, at least while using gnu-find, I'm guessing from my linuxbox.


http://home.arcor.de/hirnstrom/bewerbung
Muhammad Imad Qureshi
Ranch Hand

Joined: Sep 13, 2005
Posts: 238
You are right. I was supposed to use not newer. I created two files. One with timestamp on August 30 23:59 and other with Sep 01 12:00. Now I was trying to delete files using between these two file (newer and !newer). Problem is it was also fetching files from sub directories. I don't want to delete files from sub directories.
Stefan Wagner
Ranch Hand

Joined: Jun 02, 2003
Posts: 1923

You may use masdepth to prevent find from visting subdiers:
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: rm file on a specifc date