unix - filtering file from the result of find command -


i want particular pattern in directory of files , want exclude patterns while result displayed.

i use following command

find . -type f -exec grep -il 'foo' {} \; | find . -not -name "*.jar" -not -name "*.gz" -not -name "*.log" 2>/dev/null 

when result displayed, see following error message

find: grep terminated signal 13 

can please guide me why error message there , if there better command use getting desired result (basically excluding jar files or log files or other type of files result set)?

i think you're trying use find grep in second half of pipeline; find doesn't work that. should have in 1 command:

find . -type f -not -name "*.jar" -not -name "*.gz" -not -name "*.log" -exec grep -il 'foo' + 2>/dev/null 

or

find . -type f -not -name "*.jar" -not -name "*.gz" -not -name "*.log" -exec grep -qi 'foo' \; -print 2>/dev/null 

or let grep traverse tree , filter names after (using grep, not find):

grep -irl foo . | grep -v -e '\.jar$' -e '\.gz$' -e '\.log$' 

Comments

Popular posts from this blog

java - activate/deactivate sonar maven plugin by profile? -

python - TypeError: can only concatenate tuple (not "float") to tuple -

java - What is the difference between String. and String.this. ? -