I’ve got the following if clause:
if $(echo "$INDEX" | grep -c '^?? ' &> /dev/null) > 0 ;
It outputs count of strings matching grep expression. How can I assign that count to a variable inside an if clause, so that I don’t have to execute that command twice to get count of strings?
You assign the result of a (series of) command to a variable like this:
and then call it when it’s needed like this:
$matchedCount