Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .