How to tell "find" to not search inside hidden folders?
I basically want "find" to ignore all hidden files and folders.
I've got a command like: find ~/ -type f -name 'whatever' But it takes a while 'cos it seems to look inside all the hidden folders as well (where hidden folders are ones that begin with "."). What's the best way to search for files in my home dir, but don't bother looking inside hidden folders? I don't want it to display hidden files as well. |
The first example won't show you any hidden file or directory
Code:
find . \( ! -regex '.*/\..*' \) -type f -name "whatever" Code:
find . \( ! -regex '.*/\..*/..*' \) -type f -name "whatever" |
Thanks, what would be the equivalent for grep? Performing searches inside files, but ignoring hidden files and directories.
|
If you're performing a grep inside a file you need to specify the name. Don't specify hidden files and it won't search them, right?!
|
find . \( ! -regex '.*/\..*' \) -type f -name "whatever" -exec grep "text_to_search" {} \;
i think. |
Quote:
|
Hi robo555:
You have to do nothing. Really, hard is to grep this hidden files. I prepared a directory with three files: 2 are normal and 1 is hidden. Here is the directory: Code:
Modelo:~/teste/grep# ls -laR Code:
text1 Entering Code:
Modelo:~/teste/grep# grep HELLO * Code:
Modelo:~/teste/grep# grep -r HELLO * Code:
Modelo:~/teste/grep# grep -r HELLO * .* |
Actually, that's what I meant - grep in a directory. By default it won't look pay any attention to the hidden files.
|
Search directory for files containing string, excluding hidden files/directories
Quote:
Code:
find . \( ! -regex '.*/\..*' \) -exec grep -l "STRING_YOU_WANT_TO_CHECK_FOR" {} \;
|
All times are GMT -5. The time now is 08:12 PM. |