How to Use the Linux column Command to Format Text into Tables

When working in a Linux terminal, raw data is often output in a dense, unformatted list. If you use a command like mount to view connected drives, or if you cat a file containing hundreds of comma-separated values (CSV), the text frequently wraps erratically across the screen. Reading this jagged, unaligned data is difficult and prone to human error. To solve this, Linux provides the column command, a highly useful formatting utility that reads standard text input and automatically reconstructs it into a perfectly aligned, visually distinct grid or table, exactly like a spreadsheet.

Basic Usage: Formatting Lists into Grids

If you have a file containing a long, single-column list of words (for example, a list of 100 installed software packages), printing it to the terminal results in endless scrolling. You can pipe this data into the column command to distribute it horizontally across your screen.

cat packages.txt | column

The column command automatically detects the width of your current terminal window and arranges the list into as many perfectly aligned columns as possible, drastically reducing the vertical height of the output.

Creating Tables from Delimited Data

The true power of the column command is its ability to take delimited data (like CSV files or colon-separated system files) and format it into a readable table with distinct headers and rows.

By default, column assumes that spaces or tabs are the delimiters. If you are reading the /etc/passwd file, which uses colons (:) to separate the username, user ID, and home directory, the command will fail unless you specify the delimiter using the -s (separator) flag and the -t (table) flag.

  1. Open your terminal.
  2. Type the command, using -s ':' to specify the colon as the separator, and -t to force table formatting: cat /etc/passwd | column -s ':' -t
  3. Press Enter.

Instead of a confusing wall of colons and text, the terminal will print a perfectly spaced, highly readable table where the usernames, UIDs, and directories are strictly aligned in their own vertical columns.

Formatting Command Output

You can also use column to clean up the output of other Linux commands on the fly. For instance, the mount command is notoriously difficult to read because the device paths vary wildly in length, breaking the alignment of the output lines.

Because the mount command uses standard spaces between its words, you do not need the -s flag; you only need the -t flag to enforce the table structure:

mount | column -t

This instantly transforms the messy mount output into a pristine table, making it immediately obvious which device is mounted to which directory with which file system.

Get the best tech tips delivered straight to your inbox.

Join thousands of readers mastering Apple, Google, Microsoft, and Linux.