find or grep except on a directory

find or grep except on a directory

Posted By: pmietlicki

Published to Linux on Jun 23, 2017

grep -R --exclude-dir=node_modules 'things to find' /path/of/search

More information on : http://stackoverflow.com/q/221921/78845

FIND excluding directories foo and bar :

find /dir \( -name foo -prune \) -o \( -name bar -prune \) -o -name "*.sh" -print

By combining GREP and FIND :

find /dir \( -name node_modules -prune \) -o -name "*.sh" -exec grep --color -Hn "your text to find" {} 2>/dev/null \;

Tags: linux

Archive