Output creation date of most recently created directory

  • joebert
  • Fart Bubbles
  • Genius
  • User avatar
  • Posts: 13504
  • Loc: Florida

Post 3+ Months Ago

I'm looking for a bash/sh command I can use to output only the creation date of the most recently created directory in a sub-directory.
  • joebert
  • Fart Bubbles
  • Genius
  • User avatar
  • Posts: 13504
  • Loc: Florida

Post 3+ Months Ago

I haven't been able to find anything to find the creation date of a directory, but I do create directories by copying a template directory and there's a file in that directory that doesn't change so I can use the last modified date of that file.

It seems crude, but it works.

Code: [ Select ]
find /path -name \.htaccess -printf \"%Tm %Td %Ty\\n\" | sort -k3n -k1n -k2n | tail -n1 | awk '{print $1"/"$2"/"$3}'
  • Bigwebmaster
  • Site Admin
  • Site Admin
  • User avatar
  • Posts: 9099
  • Loc: Seattle, WA & Phoenix, AZ

Post 3+ Months Ago

I didn't do the formatting, but how about something like this:

Code: [ Select ]
ls --time=ctime --full-time | sort -k6n | tail -n1
  • joebert
  • Fart Bubbles
  • Genius
  • User avatar
  • Posts: 13504
  • Loc: Florida

Post 3+ Months Ago

One of the issues I've run into with the time attributes of the directories, is that when I update or add a file in one of the previous directories, the ctime/mtime of that old directory gets updated. So it makes that old directory look new since ctime and mtime are the same on this particular system.

This command I'm looking for revolves around Apache's mod_vhost_alias. Basically what I'm doing, is I have a template directory "_template" that I copy, "cp -r _template new-site.com" to create a shell for a new website. (kinda funny "cp -r", "breathing life" into a new site. Yeah, I'm coining that now.)

The purpose of the command, is to let me know when the last time I created a new website was, hence the creation date of the latest directory.

I was looking through date attributes yesterday, and came across a "birth" attribute that looked promising, but that attribute has been "-" on this particular server, thus useless.

I considered using "ls -U" thinking it would return the contents unsorted in the order they were created, but I got unexpected results from that.

For the time being, I'm going to stick with looking for that .htaccess file. If I have to start updating that file, thus tainting my timestamp, I'll likely add a ".birth" file to my _template and look for that.

Post Information

  • Total Posts in this topic: 4 posts
  • Users browsing this forum: No registered users and 52 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.