# echo $a
<td>Good Data 1 </td> <td>Good Data 2</td> <td>Good Data 3</td> <td>Good Data 1 </td> <td>Good Data 2</td> <td>Good Data 3</td>
# echo "$a"
<td>Good Data 1 </td>
<td>Good Data 2</td>
<td>Good Data 3</td>
<td>Good Data 1 </td>
<td>Good Data 2</td>
<td>Good Data 3</td>
Oh, and remove the <space> before and after the = sign and add a space after the echo
should be
aCount=$(echo "$a" | wc -l)
... and NOT:
aCount = $(echo"$a" | wc -l)
depending on your OS, check if there are no option needed with the echo command like echo -e or echo -n or whatever.
by the way, to troubleshoot your code, you can just add the following line
echo "a=$a"
just before the
aCount=$(echo "$a" | wc -l)
So you can check what do $a really contains and see if the 1 0 1 0 1 ... is correct... or not
The problem is that "wc" counts the number of line-feed characters. The echo "$a" line is generating a line-feed even if $a is empty.
Try avoiding the intermediate variable:
aCount=$(egrep -oh "exp" $logfiles|wc -l)
Also note the normal position of the options parameters on the "egrep" command line. Though your version happens to work for "egrep" in Linux, wandering from the command line described in a "man" page will eventually give you grief.
Also, please stop putting semi-colons at the end of lines. This is unix scripting not Oracle.