[PLUG] Control of 'ls' display

Kyle Accardi sandbox at pacifier.com
Sat Nov 23 17:55:12 UTC 2002


Rich Shepard wrote:

>   When I listed the directory contents it displayed in three columns across
> the screen. The idle thought wandered into my head that the arrangement was
> probably done by bash counting the number of files and assigning one-third
> to each display column. But, after I had converted a few dozen names, the
> display became two columns rather than three. My experience with looking at
> lots of directory displays suggests that the shell tries to fit them on a
> single line, but creates columns (down, rather than across) as the number or
> length becomes too large.
> 
>   So, just out of curiosity I would like to learn what controls this
> display. I assume that it's something within bash (or the shell of your
> choice). Is the algorithm some generally accepted standard or does it vary
> with the phase of the moon and the tides?


Not sure what process handles these but it works in a VT as well as an xterm,

$ echo $COLUMNS
92

$ echo $LINES
55


guess is that ls checks $COLUMNS and determines how many columns it can 
display based on the longest filename.

Are you asking how to make the listing go across

a b
c d

instead of down?

a c
b d

I think ls can do that, but I'm not awake enough to look.

--
Kyle Accardi





More information about the PLUG mailing list