I have find command that display files in my project:
find . -type f -not -path './node_modules*' -a -not -path '*.git*' \
-a -not -path './coverage*' -a -not -path './bower_components*' \
-a -not -name '*~'
How can I filter the files so it don't show the ones that are in .gitignore?
I thought that I use:
while read file; do
grep $file .gitignore > /dev/null && echo $file;
done
but .gitignore file can have glob patterns (also it will not work with paths if file is in .gitignore), How can I filter files based on patterns that may have globs?
man find
says: "-path pattern ... To ignore a whole directory tree, use -prune" so you want something likefind . -name .git -prune -o -name node_modules -prune -o -type f
(-o
means "or")