This answer on opening all files in vim except [condition]:
https://unix.stackexchange.com/a/149356/98426
gives an answer similar to this:
find . \( -name '.?*' -prune \) -o -type f -print
(I adapted the answer because my question here is not about vim)
Where the negated condition is in the escaped parentheses. However, on my test files, the following
find . -type f -not -name '^.*'
produces the same results, but is easier to read and write. The -not method, like the -prune method, prunes any directories starting with a . (dot). I am wondering what are the edge cases where the -not and the -prune -o -print method would have different results.
Findutils' infopage says the following:
-not expr: True if expr is false
-prune: If the file is a directory, do not descend into it. (and further explains that -o -print is required to actually exclude the top matching directory)
They seem to be hard to compare this way, because -not is a test and -prune is an action, but to me, they are interchangeable (as long as -o -print comes after -prune)
find
with-not
doesn’t exclude directories starting with.
; it will output any file name not starting with^.
, regardless of any.
s in its path components. Try it in a git workspace as muru suggested. (-name
doesn’t match regexes.).*
, it would still match filename not starting with.
inside directories whose name do start with.
.