Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

rm file on a specifc date

 
Muhammad Imad Qureshi
Ranch Hand
Posts: 238
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1923
Linux Postgres Database Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

 
Muhammad Imad Qureshi
Ranch Hand
Posts: 238
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1923
Linux Postgres Database Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You may use masdepth to prevent find from visting subdiers:
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic