GREP Excluding Hidden Directories from being scanned
I wrote a script in Bash and have a line where is does a find and includes the directories that I want and excludes the directories that I dont.
Code:
find $home_dir -depth | grep -f include | grep -v -f exclude Code:
/home/testuser/.* |
Did you try with the * removed ?
(edit) Try: Code:
find $home_dir -depth ! -name ".*" | grep -f include |
thanks for the reply,
I can successfully use: Code:
find $home_dir -depth ! -path '*\/.*"| grep -f include | grep -v -f exclude Code:
*\/.* Code:
find $home_dir -depth ! -path '*\/.*"| grep -f include | grep -v -f exclude |
In this case, I would just update the exclude file before, with
Code:
find $home_dir -type d -name ".*" >> exclude Code:
find $home_dir -depth | grep -f include | grep -v -f exclude... |
grep uses regular expressions, find -name uses glob patterns. To exclude hidden files with regexps use:
Code:
/\. |
Awesome stuff,
I ended doing this and all worked like a charm Code:
find /home/testuser -maxdepth 1 -type f -name ".*" >> /home/testuser/exclude Code:
find /home/testuser -depth -type d -name ".*" >> /home/testuser/exclude |
The ntubski's suggestion doesn't work ?
|
All times are GMT -5. The time now is 09:08 AM. |