Find command search directories created after a specific date in Linux / Cygwin

I want to use the find command to search for these directories:

Access: 2013-12-13 10:59:46.190886900 -0500 Modify: 2013-12-03 07:04:02.995890600 -0500 Change: 2013-12-03 07:04:02.995890600 -0500 Birth: 2013-12-02 07:04:02.000000000 -0500 (I want a time after '12-03') 

This is the command I ran, but it still contains lists of old directories:

 find . -type d -newerBt '2013-12-03 00:00:00' -exec du -h {} \; 

How can I change this line to find directories created after this date? What is the difference between -newerct and -newerBt. I think I want a date of birth.

Note. I am running this with the latest cygwin.

+7
linux bash find cygwin
source share
3 answers

Instead, you can use stat:

  find . -type d -exec bash -c '(( $(stat -c %W "{}") > $(date +%s -d '2013-12-03') )) && du -h "{}"' \; 
+3
source share

You are finding directories, but showing the files contained in it.

These files may have birth dates that are earlier than in the directory. For example, create a file, then a directory and move the file to this directory.

This is the difference between the date of birth and the date of change. If the file is moved to a directory, the directory changes, so I think -newerct is what you want.

+1
source share

Interestingly, a problem with TimeZone? What is echo $TZ ? What happens if you run unset TZ (and unsetenv TZ also in csh ) and repeat the same commands?

Here is an excerpt of the man page for -newerXY. Maybe reading it will cause some thoughts?

  -newerXY reference Compares the timestamp of the current file with reference. The reference argument is normally the name of a file (and one of its timestamps is used for the comparison) but it may also be a string describing an absolute time. X and Y are placeholders for other letters, and these letters select which time belonging to how reference is used for the comparison. a The access time of the file reference B The birth time of the file reference c The inode status change time of reference m The modification time of the file reference t reference is interpreted directly as a time Some combinations are invalid; for example, it is invalid for X to be t. Some combinations are not implemented on all systems; for example B is not supported on all systems. If an invalid or unsupported combination of XY is specified, a fatal error results. Time specifications are interpreted as for the argument to the -d option of GNU date. If you try to use the birth time of a reference file, and the birth time cannot be determined, a fatal error message results. If you specify a test which refers to the birth time of files being examined, this test will fail for any files where the birth time is unknown. 
0
source share

All Articles