column
Format data into aligned columns
TLDR
Format the output of a command for a 30 characters wide display
Split columns automatically and auto-align them in a tabular format
Specify the column delimiter character for the --table option (e.g. "," for CSV) (defaults to whitespace)
Fill rows before filling columns
SYNOPSIS
column [OPTIONS] [FILE...]
PARAMETERS
-t, --table
Determines the number of columns in the input and creates a table. This is often the most useful option for tabular data.
-s, --separator=CHARS
Specifies custom input item separator(s). By default, column uses whitespace as a separator.
-o, --output-separator=CHARS
Specifies the string to use as a column separator in the output. Default is two spaces.
-c, --columns=NUM
Output is formatted to exactly NUM columns. This overrides automatic column determination.
-x, --fill-rows
Fill columns before filling rows. This means data will flow horizontally first, then wrap to the next row.
-n, --no-indent
Don't indent the first column. Useful when the first column doesn't need extra padding.
-R, --right-justify
Right justifies text within all columns. By default, columns are left-justified.
-L, --logical
Use logical character counts rather than byte counts for column width, important for multi-byte characters.
-W, --width=WIDTH
Specify the maximum display width. If not set, it defaults to the terminal width.
DESCRIPTION
The column command is a versatile utility used to format its input into multiple columns, significantly enhancing the readability of tabular data in the terminal. It reads lines from standard input or specified files and intelligently arranges them into columns, automatically padding entries to ensure proper alignment.
Its primary function is to transform unstructured or line-oriented text into a more organized, grid-like format. For instance, the output of commands like ls -l or ps aux can be piped to column -t to automatically create a neat table.
Key features include the ability to automatically determine the optimal number of columns (table mode), specify custom input and output delimiters, control column width, and sort output. It is an invaluable tool for system administrators and developers who frequently work with command-line output and require clear, aligned data presentation.
CAVEATS
While powerful for general tabular formatting, column is not designed for complex, highly customized text manipulation that requires advanced conditional formatting or numeric operations. For such tasks, tools like awk or printf are more suitable.
The automatic table mode (-t) relies on consistent delimiter usage in the input. If the input data has inconsistent delimiters or varying numbers of fields per line, the output might not be as expected.
Handling of non-printable characters or very long lines without breaks can sometimes lead to unexpected visual output.
COMMON USAGE EXAMPLE
A very common use case for column is to make the output of commands like ls -l more readable:
ls -l | column -t
This command takes the long listing output of ls and automatically formats it into neatly aligned columns, making it much easier to scan and understand.
INPUT AND OUTPUT
column reads data from standard input if no file is specified, or from the files listed as arguments. The formatted output is always written to standard output. This makes it ideal for piping the output of other commands directly into column for immediate formatting.
HISTORY
The column command is part of the util-linux package, a collection of essential Linux utilities. It has been a standard feature of Unix-like operating systems for many years, evolving to include more sophisticated formatting options like the -t (table) mode, which significantly increased its utility for presenting structured data. Its development has focused on providing a fast and efficient way to make plain text output more readable, adapting to modern terminal capabilities and diverse data formats.