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.

What would be a good way, via the Bash command-line, to find the time of the last modification made to any of the files in a particularly directory?

Basically, I'm working on a project where all the project's files are within one directory, and I'm keeping a timesheet, and I forgot to note when I finished working on the project earlier today. Whichever file was modified last will give me that time.

I could guess at the time... but I thought it would be fun to get Bash to give me a more accurate answer :)

As an added bonus, I think the command will likely need to ignore certain directories, in particular the .git directory in this case.

share|improve this question
add comment

3 Answers

up vote 2 down vote accepted

I'm not sure what you're after, but this should work for quick checks:

ls -tl
share|improve this answer
1  
I usually use ls -ltr so that the newest are at the bottom, it makes it easy to see them when there's a lot of files scrolling by. –  ZimmyDubZongyZongDubby Jan 7 '10 at 20:01
add comment

I prefer ls -lrt, especially if there are lots of files. The t says to sort by modification time, and the r says to reverse the sort. This way the newest files are listed last, and will still be in the window without scrolling.

share|improve this answer
add comment

To narrow down a guess (here 50 minutes ago) while looking recursively in a directory structure and excluding a couple of paths:

find -name .git -prune -o -name another_exclusion -prune -o \( -newermt "now - 50 min" -ls \)
share|improve this answer
add comment

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.