Exclude hidden files when searching with Unix/Linux find?
--------------------------------------------------
Rise to the top 3% as a developer or hire one of them at Toptal: https://topt.al/25cXVn
--------------------------------------------------
Music by Eric Matyas
https://www.soundimage.org
Track title: Popsicle Puzzles
--
Chapters
00:00 Exclude Hidden Files When Searching With Unix/Linux Find?
00:09 Answer 1 Score 26
00:20 Accepted Answer Score 19
00:26 Answer 3 Score 14
00:44 Answer 4 Score 10
00:57 Answer 5 Score 3
01:19 Thank you
--
Full question
https://superuser.com/questions/152958/e...
--
Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...
--
Tags
#linux #commandline #unix #find
#avk47
Rise to the top 3% as a developer or hire one of them at Toptal: https://topt.al/25cXVn
--------------------------------------------------
Music by Eric Matyas
https://www.soundimage.org
Track title: Popsicle Puzzles
--
Chapters
00:00 Exclude Hidden Files When Searching With Unix/Linux Find?
00:09 Answer 1 Score 26
00:20 Accepted Answer Score 19
00:26 Answer 3 Score 14
00:44 Answer 4 Score 10
00:57 Answer 5 Score 3
01:19 Thank you
--
Full question
https://superuser.com/questions/152958/e...
--
Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...
--
Tags
#linux #commandline #unix #find
#avk47
ANSWER 1
Score 26
It seems negation glob pattern is not well known. So you can use:
find . -name "[!.]*"
ACCEPTED ANSWER
Score 19
I found this here:
find . \( ! -regex '.*/\..*' \) -type f -name "whatever"
ANSWER 3
Score 14
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.
ANSWER 4
Score 10
Try the following find
usage:
find . -type f -not -path '*/\.*'
Which would ignore all the hidden files (files and directories starting with a dot).
ANSWER 5
Score 3
fd
Use fd
, a simple, much faster and user-friendly alternative to find
. By default, it:
- Ignores hidden directories and files, by default.
- Ignores patterns from your
.gitignore
, by default.
Check the Benchmark analysis.