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

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

1 Answer

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-
link|improve this answer
And this will work in Windows too? Please note that OP did not specify his operating system. – Randolph West Feb 21 '11 at 8:08
Oh well, so true. – Olli Feb 21 '11 at 8:09
feedback

Your Answer

 
or
required, but never shown

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