Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

What is the significance of importance of the command export COLUMNS ?

What I know is that it's a global variable.

I frequently see it in the beginning of *nix scripts.

share|improve this question
up vote 2 down vote accepted

It is the width of your current terminal window measured as the number of ASCII characters.

From man bash :

          Used  by  the  select  builtin command to determine the terminal
          width when printing selection  lists.   Automatically  set  upon
          receipt of a SIGWINCH.

Also in the more generic ksh :

                 If this variable is set, the value is used to define  the
                 width of the edit window for the shell edit modes and for
                 printing select lists.

For practical part, notice that the value of this variable changes when the dimensions of your virtual terminal window change. (This is when the above mentioned SIGWINCH is sent to the active shell).

share|improve this answer

This answer is something of a guess, given that you didn't say on what kind of system you see this, Solaris, HP-UX, AIX, a BSD, Linux (what distro?), etc...

Shell scripts that did curses-style interaction with users would set environment variables ROWS and COLUMNS in the past.

Curses-style interactivity dates from before windowing systems, so those programs typically didn't do whatever it took to understand what size an xterm window was. So a lot of curses-based programs used environment variables ROWS and COLUMNS to decide how to lay out their fields and labels.

Sometimes, shells would try to find and set ROWS and COLUMNS environment variables when they started running in an xterm. A lot of older SunOS and Solaris systems would have /etc/profile do this. Sometimes a SIGWINCH (in SunOS and Solaris, at least) would get used to set the ROWS and COLUMNS variables. Vendors used to modify xterm in silly ways, and often would ruin passing SIGWINCH to the process group running in an xterm, and curses-style interaction would look really bad.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.