$ tree -D
.
├── [Jun 25 18:46] dir1
│ └── [Jun 25 18:51] file1
└── [Jun 25 17:59] dir2
└── [Jun 25 18:46] file2
2 directories, 2 files
$ ls -l /tmp/since
-rw-r--r-- 1 xxx None 0 Jun 25 18:45 /tmp/since
It is not clear, why the dir1 folder which is correctly getting excluded
$ find . -name dir1 -prune -o -type f -print
./dir2/file2
in above command, shows up in following command
$ find . -name dir1 -prune -o -type f -newer /tmp/since
./dir1
./dir2/file2
How can I rewrite above find command to list only files that changed since timestamp of file /tmp/since, without visiting folder 'dir1'?
When you do :
$ find . -name dir1 -prune -o -type f -newer /tmp/since
find
adds implicitly a -print
to make it become
$ find . \( -name dir1 -prune -o -type f -newer /tmp/since \) -print
As -name dir1 -prune
is true for dir1
, -print
is executed, even though the children of dir1
are not processed.
When you add -print
explicitly, it is interpreted as :
$ find . \( -name dir1 -prune \) -o \( -type f -newer /tmp/since -print \)
so when -name dir1 -prune
is true, the rest is bypassed, hence dir1
is not printed.