Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

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

Your Answer


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.