[OpenIndiana-discuss] using touch ... whats wrong here

Peter Tribble peter.tribble at gmail.com
Thu Dec 3 09:56:01 UTC 2015


On Thu, Dec 3, 2015 at 7:52 AM, Harry Putnam <reader at newsguy.com> wrote:

> Not particularly and OI question but that is where I need this
> technique to work.  I'm hoping some of you old shell hands will
> see the problem.
>
> I hope not to be exibiting true ignorance... but here I go.
>
> I keep messing with one forumlation of find cnmd that seems like it
> aught to work...  What am I doing wrong or not understanding?
>
> I'm trying to use finds' -c newer technique
>
> Check on just two of many files with following dates.
>
>   Two of quite a few files in this location:
>   -rwxr-xr-x 1 harry nfsu 1768 2014-07-22 20:18 scripts/perl/getad
>   -rwxr-xr-x 1 harry nfsu 6429 2014-07-22 20:18 scripts/perl/rnami.pl
>
> To my eye, those dates fall within the targetting files
>
> Now create our targeting files with target date inbetween
>
>   touch NewerThan -t 201406141130
>
>   touch ButNotNewerThan -t 201408141130
>
> Now check my targeting files:
>
>   ls -l NewerThan ButNotNewerThan
>   -rw-r--r-- 1 harry nfsu 0 2014-08-14 11:30 ButNotNewerThan
>   -rw-r--r-- 1 harry nfsu 0 2014-06-14 11:30 NewerThan
>
> Ok, now try it up
>
>   find scripts/perl/ -cnewer NewerThan -and ! -cnewer ButNotNewerThan
>
>   (Nada)
>
> Where is the flaw?
>

You're mixing the various timestamps.

A file has three timestamps:

access, shown by ls -lu
modify (of data), shown by ls -l
creation (or modify metadata), shown by ls -lc

Using find -cnewer (a gnu extension) looks at the creation time. The
creation time of the
files you're using as the comparison will be just now, so won't work. If
you want to compare
against the regular modification time (which is the time shown in your ls
output), then just
use -newer.

-- 
-Peter Tribble
http://www.petertribble.co.uk/ - http://ptribble.blogspot.com/


More information about the openindiana-discuss mailing list