Exclude hidden files when searching with Unix/Linux find?
Solution 1:
I found this here:
find . \( ! -regex '.*/\..*' \) -type f -name "whatever"
Solution 2:
It seems negation glob pattern is not well known. So you can use:
find . -name "[!.]*"
Solution 3:
This doesn't answer your question, but for the task of finding non-hidden files I like to let find find all the files then filter with grep.
find . -type f | grep -v '/\.'
Similar to your approach but perhaps a bit simpler.
Solution 4:
Try the following find
usage:
find . -type f -not -path '*/\.*'
Which would ignore all the hidden files (files and directories starting with a dot).
Solution 5:
If you aims is to find
and grep
, ripgrep
does exclude hidden files by default, e.g.
rg --files
--files
Print each file that would be searched without actually performing the search.