Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

How to find the latest one modified file by "find" command in directory and subdir ? I need take only one file.

share|improve this question
3  
In what operating system? –  Multiverse IT Feb 21 '11 at 8:02

1 Answer 1

In Linux you can use

find . -type f -printf "%TY-%Tm-%Td %TT %p\n" | sort | tail -n 1

That'll list all files (-type f) and print those with timestamps, then sort and print only last one.

If you don't want to print timestamp too, you can use

find . -type f -printf "%TY-%Tm-%Td %TT %p\n" | sort | tail -n 1 | cut -d " " -f 3-
share|improve this answer
    
And this will work in Windows too? Please note that OP did not specify his operating system. –  user3463 Feb 21 '11 at 8:08
    
Oh well, so true. –  Olli Feb 21 '11 at 8:09

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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