>>926
とりあえず、その部分の改行を取るだけなら、

echo `grep "A" logfile | wc -l ; grep "B" logfile | wc -l` >> hoge.txt

にすればいいわな。