I have a directory called /home/mydir/test A file will be sent from some other team which lands in this directory. How to find the file is whether in that directory for more than 4 hours.

I tried the below code.

find . -cmin -240 

I don't think this is working . It lists all the file in the folder. What i want is to get the file names of the files which are in this directory for more than 4 hours. How to get that?


Need +240, instead of -240.

find . -cmin +240 

You might want to add -type f so only shows filenames and not directory names

find . -cmin +240 -type f
  • yes it's working fine now but i have a doubt , is it possible to print just the file name ? it prints with './' before the file name – VRVigneshwara Sep 5 '15 at 11:43
find . -cmin +240 -type f -exec basename {} \;

That will execute basename on each file found and provide only the name of the file.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.