i asked to write script that searching recursively for files that match to the pattern ".foo" BUT the only files which exist in directories that match to the same pattern ".foo". i tried: script name : search_for_foo
function foo_search { while read line; do echo "$line” done < "$1" } for file in ${*:1}; do if [[ $file == *.foo* ]]; then if [[ -f "$file" ]]; then foo_search $file fi if [[ -d "$file" ]]; then search_for_foo $file/* fi fi done <"$1" it has to work this way : ./search_for_foo --some_file--
thanks in advance