Dear Maintainer,
Quoth POSIX.1-2024:
103406 ENVIRONMENT VARIABLES
103407 The following environment variables shall affect the execution of ls:
103408 COLUMNS Override the system-selected horizontal display line size, used to determine the
103409 column position width for writing multiple text-column output. See XBD Chapter
103410 8 (on page 167) for valid values and results when it is unset or null. The ls utility
103411 shall use this value to calculate how many pathname text columns to write (see
103412 −C). The column width chosen to write the names of files in any given directory
103413 shall be constant. Filenames shall not be truncated to fit into the multiple text-
103414 column output.
Quoth UNIX™ System V ‒ Release 2.0 User Reference Manual, DEC™ Processors (1984):
There are three major listing formats. The default format is to list one entry
per line, the -C and -x options enable multi-column formats, and the -m
option enables stream output format in which files are listed across the page,
separated by commas. In order to determine output formats for the -C, -x,
and -m options, /s uses an environment variable, COLUMNS, to determine the
number of character positions available on one output line. If this variable is
not set, the terminfo database is used to determine the number of columns,
based on the environment variable TERM. If this information cannot be
obtained, 80 columns are assumed.
Compare:
$ /bin/ls
a baba.gif boot.dump dead.letter dump1.stty dump1.worms.c dump2.stty dump2.worms.c equivs rustup-init setup.log tarta.d worms.c
awk bin code dump1.cmd dump1.worms dump2.cmd dump2.worms dupa reportbug.report~ rustup-init.sh src worms
$ COLUMNS=80 /bin/ls
a baba.gif boot.dump dead.letter dump1.stty dump1.worms.c dump2.stty dump2.worms.c equivs rustup-init setup.log tarta.d worms.c
awk bin code dump1.cmd dump1.worms dump2.cmd dump2.worms dupa reportbug.report~ rustup-init.sh src worms
Best,