I'm either now a leet UNIX hax0r or entirely insane. I can't quite tell.
echo 'select topic_id, max(post_id) from phpbb_posts group by topic_id;' | mysql --password --database=forum -B | sed 1d | sed 's/([[:digit:]]+)\t([[:digit:]]+)/update phpbb_topic set topic_last_post_id=\2 where topic_id=\1;/' | mysql --password --database=forum
Actually, I know I'm not a leet UNIX hax0r, because it doesn't work yet. Until then, I'm merely entirely insane. But then, I have a deep-seated urge for a cola. So maybe I am.
Update: OK, I admit I'm not a sed guru, so I used perl instead:
echo 'select forum_id, max(post_id) from phpbb_posts group by forum_id;' | mysql --password --database=forum -B | sed 1d | perl -ne 'my ($a, $b) = split /\t/; print "update phpbb_forums set forum_last_post_id=$b where forum_id=$a;\n";' | mysql --password --database=forum
And it worked, mostly, but I'm still missing something that's broken phpBB a little--but that part's blissfully over.