LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   To check whether a directory is created today or not (https://www.linuxquestions.org/questions/linux-newbie-8/to-check-whether-a-directory-is-created-today-or-not-4175459407/)

iruhdam 04-24-2013 03:53 AM

To check whether a directory is created today or not
 
Hi all,

I want to check whether a particular directory is created today or not.How can i??

Thanks in advance.

pan64 04-24-2013 04:01 AM

it depends on the filesystem. I think you can do it on ntfs, but not available on ext4

chrism01 04-24-2013 04:04 AM

Try the stat cmd http://linux.die.net/man/1/stat, but note that historically, *nix doesn't have a concept of 'creation time'
https://en.wikipedia.org/wiki/Stat_%28system_call%29

Very recently, moves have been made to provide a 'birth time' as well, but this is not generally implemented as of yet.

JackHamm3r 04-24-2013 07:27 AM

Try doing like this
# ls -dl directory

This'll show you tha date and time of creation of the directory, along with permissions although
Look for the info by the end of the STDOUT


Cheers!

shivaa 04-24-2013 09:18 AM

As already mentioned, you cannot see the file creation time in Unix. So a little hope is to search the directory by it's last modified time. Or on the other hand, if directories are created using some script (or even manually), create them with time stamp in their names as:
Code:

~$ find /path/to/search -name 'dir_name' -mtime -1 -type d -print
~$ mkdir dir_name.$(date +%Y%m%d)


Madhu Desai 04-24-2013 10:11 AM

Code:

$ find /source-path -type d -newermt $(date +"%Y-%m-%d")


All times are GMT -5. The time now is 12:05 PM.