My code
var=34
find $1 -type f | while read line;
do
file_status=`file "$line"`
file_name=`echo $line | sed s/".*\/"//g`
line_length=${#file_name}
if [ $line_length -gt $n ]; then
echo "hi there"
var=$((var+1))
fi
done
echo $var
I can see the message hi there for multiple times, but my variable will be 34 after i'm done with the while loop.