Parsing Tabular Output in Linux With column

The Linux column command, provided by the util-linux package, is a dedicated command-line utility designed to format unstructured text, delimited streams, and lists into neatly aligned tabular structures. This article explains how the Linux operating system uses the column command to process tabular data, covering its core parsing flags, delimiter handling, header injection, and modern structured output generation like JSON.

Core Mechanics of the column Command

The column utility reads from standard input (stdin) or a specified file and dynamically calculates whitespace padding to align text along vertical axes. By default, it organizes input lines into multiple columns to fit the width of the terminal.

To display standard terminal commands in a clean table, pipe output directly into column:

mount | column -t

The -t (table) option tells column to determine the number of columns the input contains and generate an aligned table rather than simply wrapping words across the screen.

Parsing Delimited Data

Raw system data often relies on delimiters such as commas, tabs, or colons. The column command manages these formats using two primary flags:

Example: Parsing Colon-Separated Files

System files like /etc/passwd use colons to separate user attributes. To parse this into an aligned table:

column -s ":" -t /etc/passwd

Example: Customizing Output Delimiters

To retain a specific separator (such as a vertical pipe |) while standardizing spacing, combine -s with -o:

column -s "," -o " | " -t data.csv

Adding and Managing Column Headers

Linux users can assign readable column labels directly through the command line without modifying the underlying raw data.

The -N option defines a comma-separated list of column names:

cat /etc/group | column -s ":" -t -N "Group Name,Password,GID,Users"

To underline or format these headers visually in terminal environments, the -H option can hide specific headers or apply standard table formatting styles supported by the terminal.

Column Alignment and Truncation

Modern implementations of column allow control over text alignment per column:

cat disk_usage.txt | column -t -R 2,3,4
column -t -W Description data.txt

Modern Script Integration: JSON Output

Recent versions of the util-linux suite allow column to export structured JSON using the -J flag. When combined with -t and -N, column converts raw delimited streams into structured data suitable for automated parsing by tools like jq or external APIs:

cat /etc/passwd | column -s ":" -t -N "user,pass,uid,gid,comment,home,shell" -J

This bridge between unstructured shell streams and modern data interchange formats makes column an effective tool for both visual inspection and data pipeline normalization in Linux.