linux – Get the date of the most recent entry (file or directory) within a directory – Stack Overflow


linux – Get the date of the most recent entry (file or directory) within a directory – Stack Overflow

I have a bunch of directories with different revisions of the same c++ project within. I’d like to make things sorted out moving each of these directories to a parent directory named by pattern of YYYY.MM.DD. Where YYYY.MM.DD is the date of the most recent entry (file or directory) in a directory.

How can I recursively find the date of the most recent entry in a particular directory?

Below is one of the ways to do it:

find . -not -type d -printf “%T+ %p\n” | sort -n | tail -1

Or even: find . -not -type d -printf “%TY.%Tm.%Td\n” | sort -n | tail -1

Advertisements
This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s