I have a program that is writing info out to the console - and I need
to know where to wrap the lines.

How does one go about finding the width of a console on linux?  Or
(shudder) on windows?

I've discovered that on linux, at the command prompt, I can do "echo
$COLUMNS", and it gives me the number that I want, but this variable
doesn't seem to be exported.  It doesn't appear in my env - and
consequently, I haven't figured out a way to get at it from a program
that I launch on the console.

And I haven't yet found anything on windows that would tell me the
current console width.

Does anyone know offhand?

I'm having a lot of difficulty crafting a useful google query for this one.

Thanks,

Dan