#!/bin/sh total=0 textfile=0 while read line do export total=`expr $total + 1` if [ "`printf "$line" | grep text`" != "" ] then export textfile=`expr $textfile + 1` echo "$textfile" fi done <<< "$(find . -type f)" echo $total echo $textfile