Find command search only not hidden directories

In the next command, I want to search only for hidden directories, how to do this using the following command. Ignore hidden directories when searching a log file

find /home/tom/project/ -name '.log.txt' ls /home/tom/project/ dir1 dir2 .backup .snapshot/ .ignore/ 
+6
source share
2 answers

Try

 find /home/tom/project -type d -name '.*' -prune -o -name .log.txt -print 
+4
source

This will find all files, but ignores those starting with so-called hidden files.

 find /home/tom/project/ -type f \( -iname ".log.txt" ! -iname ".*" \) 

EDIT: If the above does not work, this should do the trick. It has the best regular expression.

 find /home/tom/project/ \( ! -regex '.*/\..*' \) -type f -name ".log.txt" 

EDIT2:

Next, hidden folders will be hidden, but they will search for hidden files with a programmed template:

 find /home/tom/project/ \( ! -regex '.*/\..*/..*' \) -type f -name ".log.txt" 

EDIT3:

Grep solution :) if this does not work i get lost :)

 find /home/tom/project/ \( ! -regex '.*/\..*/..*' \) -exec grep -l ".log.txt" {} \; 

EDIT4:

Have you tried simple solutions?

 find /home/tom/project/ -type f -name ".log.txt" 

OR

 find /home/tom/project/ -type f -name "*" -exec grep -l ".log.txt" {} \; 
+1
source

Source: https://habr.com/ru/post/911833/


All Articles