How to remove all the files in the current folder that are created after the specific time?!

I want to remove all the files in the current folder that are created after the 17:00h (for example)!

P.S.:I don't need a script for this to schedule it, just for a one time execution.

I supose that i need to use the rm and find commands, but.. how?!
oky-dokyAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ahoffmannCommented:
assuming you have a file with timestamp 17:00, then do

find . -type f -newer ./file-of-17:00 -exec rm {} \;

(use ls instead of rm for testing)
0
oky-dokyAuthor Commented:
Nice, but.. isn't working!

For an example (on the concrete example), i have the next:
-rw-r--r--      1      user      is06      16      Apr      20      14:13      dat1.txt
-rw-r--r--      1      user      is06      0      Apr      20      14:14      dat1.txt

...and i want to remove all the files that are created after the 14:00, then i'll need to write:
find . -type f -newer ./file-of-14:00 -exec rm {} \;
or
find . -type f -newer ./file-of-14:00 -exec ls {} \;

The results are:
find: ./file-of-14:00: No such file or directory

Something needs to be changed...
0
ahoffmannCommented:
> .. ../file-of-14:00
> find: ./file-of-14:00: No such file or directory
you have to use a real existing filename
0
Cloud Class® Course: Amazon Web Services - Basic

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

oky-dokyAuthor Commented:
I don't understand this "real existing filename".
Why can't i find that two files dat1.txt & dat2.txt - which are created AFTER the 14:00?!
0
ahoffmannCommented:
> Why can't i find that two files dat1.txt & dat2.txt - which are created AFTER the 14:00?!
cause you need a file which was created BEFORE 14:00
find itself can only use timestamps older than 24 hours, see man find

> I don't understand this "real existing filename".
if you have a file named timestamp, where you see with:
  ls -l timestamp

somthing like:

-rw-r--r--     1     user     is06     16     Apr     20     14:00     timestamp

then your find looks like:

  find . -type f -newer ./timestamp -exec ls {} \;
0
oky-dokyAuthor Commented:
OK! That is correct, full working!

Now i understand what you all the time are trying to "show" me!

Conclusion: this is a method of removing (if rm is used) the files which are newer than the specified file (timestamp).

Now i have the different "idea" (question): is it possible to remove all the files without specifieng that "timestamp" file which is actually created at 14:00? Can it be done with some other command, maybe?
0
ahoffmannCommented:
> .. is it possible to remove all the files without specifieng that "timestamp" file
not with find

> Can it be done with some other command, maybe?
hmm, I'm not aware of a single command doing that.
I'd use
  touch `date +%m%d`1400 timestamp
  find . -type f -newer ./timestamp -exec ls {} \;
(some systems allow this kind of touch command as user root only)
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
oky-dokyAuthor Commented:
Thanks, ahoffmann!

Only what left tricky (for me!) is this touch command which is creating a file named "timestamp" and should set it to 14:00 (date of creation), but that just isn't working - file is created and set on the current system time.

Easier whould be (which is working well):
      touch -d1400 timestamp

THANKS again!!! You're the legend!

[btw.. that was my first question asked on experts-exchange.com - which cost me some points, but points spent on that in comparison to knowledge what i have now.. :]!

Greetings from Croatia [HRVATSKA]:)!
0
ahoffmannCommented:
glad to have helped you
dobro dan ;-)
0
oky-dokyAuthor Commented:
Very nice (try:)..

It's a night [21:48h] but that's not so important..

dobar dan:)!!
0
ahoffmannCommented:
hehe, that's (beside pievo) what remains from last holidays
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Unix OS

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.