#!/bin/bash function check_tool { if grep \ --quiet \ --no-messages \ --recursive \ --fixed-strings \ --binary-files=without-match \ --include='*.php' \ --include='*.sql' \ --include='*.py' \ --include='*.java' \ --include='*.pl' \ --include='*.bash' \ --include='*.sh' \ --include='*.c' \ --include='*.cxx' \ --include='*.cpp' \ --include='*.cc' \ --include='*.C' \ --include='*.c++' \ wb_terms \ "/data/project/$1/"; then printf '%s\n' "$1" else status=$? case $status in 1) # no match return 0 ;; 2) printf >&2 'grep error while searching tool %s\n' "$1" return 2 ;; *) printf >&2 'unknown grep exit code while searching tool %s: %d\n' "$1" "$status" return $status ;; esac fi } if (($#)); then for tool; do check_tool "$tool"; done else cd /data/project for dir in */; do tool=${dir%/} check_tool "$tool" done fi