Errors with a shell-script <p>i found some freaky error. I want to increment a counter, but the variable isnt visible outside the while do.</p> <p>The script as follows:</p> <pre><code> ## $1 - The file which should be examined ## $2 - The time passed between the checks. If $2 is 5 then all lines from the last 5 minutes are taken ## $3 - The Errormessage to search for outputOK="OK - nothing happened" output_logcheck=0; errlines=""; cat $1 | grep "$3" | while read line do linedate=`date -d "$(echo $line | cut -d " " -f 2)" '+%s'` nowdate=`date '+%s'` if [ $(( $nowdate - (60 * $2) )) -le $linedate ] then $output_logcheck=$[$output_logcheck+1] $errlines="${errlines} -- ${line}" fi done; if [ $output_logcheck -eq 0 ] then echo $outputOK else echo "CRITICAL - There are -= ${output_logcheck} =- $3 -- Lines: $errlines" fi </code></pre> <p>So i dont know what else to try. Thanks in advance.</p>