On 18/08/2014 15:02, Stroller wrote:

On Mon, 18 August 2014, at 1:16 pm, Kerin Millar <kerfra...@fastmail.co.uk> 
wrote:
...
        (( count += matches ))
    done < <(grep -hcm1 -F "$string" ${files[*]})

Oh, this is lovely.

I've learned some things today.

    if (( count == ${#files[@]} )); then

May I ask why you prefer these brackets for evaluation, please?

There was no particular reason, other than to maintain consistency in the example (both for evaluation and as an alternative to expansion). Sometimes, I find double square brackets to be a bit of an eyesore, but do tend to use them more often than not.

I particularly like double parentheses for checking exit codes assigned to variables. For example:

(( $? )) && echo "something went wrong"

As opposed to having to perform an explicit comparison:

[[ $? != 0 ]] && echo "something went wrong"

--Kerin

Reply via email to