Reputation: 196
Given:
/path/to/repos
.myrepo
repository were modified after a particular time.find /path/to/repos/myrepo -type l
prints no results, showing that myrepo
's directory structure contains no symlinks./path/to/repos/myrepo/.git
has a modification time more recent than the one I'm interested in, but no other files in myrepo
or any of its subdirectories do.When I enter the following command, I see no results:
find /path/to/repos/myrepo -name .git -prune -o -path '/path/to/repos/myrepo/*' -newermt '2020-05-18 15:52:34' -print
Yet when I add a trailing slash to the starting point,
find /path/to/repos/myrepo/ -name .git -prune -o -path '/path/to/repos/myrepo/*' -newermt '2020-05-18 15:52:34' -print
the command prints /path/to/repos/myrepo/
.
Why this difference?
Upvotes: 2
Views: 614
Reputation: 196
GNU Find preserves the starting-point as entered, so in the first example, /path/to/repos/myrepo
doesn't match -path '/path/to/repos/myrepo/*'
because the path expression includes a trailing slash and there is no trailing slash in the directory name.
In the second example, since the directory name does include a trailing slash, it successfully matches the path expression /path/to/repos/myrepo/*
.
The -newermt
test is irrelevant here. Note that the other paths processed by find
in these examples are identical, regardless of whether the starting-point contained a trailing slash. I.e., if myrepo
contains a file xyz
, it is processed as /path/to/repos/myrepo/xyz
in both cases. In other words, for subpaths of the starting-point, a trailing slash is appended to the starting-point if needed; this just doesn't apply to the starting-point itself.
Upvotes: 3