Sunday, May 5, 2024
2
rated 0 times [  2] [ 0]  / answers: 1 / hits: 200598  / 3 Years ago, fri, september 17, 2021, 10:34:11

Starting from (notice the wildcards before and after "some text")



find . -type f -name '*some text*'


how can one exclude/ignore all hidden files and directories?



I've already been googling for far too long, came across some -prune and ! (exclamation mark) parameters, but no fitting (and parsimonious) example which just worked.



Piping | to grep would be an option and I'd also welcome examples of that; but primarily I'm interested in a brief one-liner (or a couple of stand-alone one-liners, illustrating different ways of achieving the same command-line goal) just using find.



ps: Find files in linux and exclude specific directories seems closely related, but a) is not accepted yet and b) is related-but-different-and-distinct, but c) may provide inspiration and help pinpoint the confusion!



Edit



find . ( ! -regex '.*/..*' ) -type f -name "whatever", works. The regex looks for "anything, then a slash, then a dot, then anything" (i.e. all hidden files and folders including their subfolders), and the "!" negates the regex.


More From » command-line

 Answers
6

The answer I originally posted as an "edit" to my original question above:



find . ( ! -regex '.*/..*' ) -type f -name "whatever", works. The regex looks for "anything, then a slash, then a dot, then anything" (i.e. all hidden files and folders including their subfolders), and the "!" negates the regex.


[#32282] Saturday, September 18, 2021, 3 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
hergy

Total Points: 64
Total Questions: 115
Total Answers: 109

Location: Saint Helena
Member since Tue, Nov 3, 2020
4 Years ago
;