Overview
Capturing terminal text streams or documentation from Linux manual pages frequently introduces broken layouts caused by embedded backspaces and terminal escape sequences. This tutorial explores the operational behavior of the col utility on Ubuntu 24.04, detailing flag variations and real-world techniques for preparing clean, readable text files.
Fundamental Concepts & Filtering Backspaces with col
To begin exploring col, verify that the system has bsdextrautils installed, which provides the binary.

The col filter strips reverse line feeds, eliminates backspaces, and regularizes whitespace formatting across Unix streams. Executed in its default state without additional switches, it processes backspaced character combinations by superimposing colliding glyphs.
⚙️ [Core Options]
-b : Strips backspace characters completely, retaining only the final character rendered at any column position.-f : Permits half-line feeds in the forward direction.-p : Passes through unrecognized control sequences without suppressing them.-x : Converts hard tab characters into equivalent sequences of space characters.-l num : Sets the maximum line buffer capacity held in memory.

Feeding a tab-delimited (\t) string into col outputs cleanly aligned columns across standard terminal stops:

Exporting Clean Man Pages to Plain Text (col -b)
Create an isolated directory to carry out these exercises and switch into it.

Passing the man ls documentation pipeline through col -b strips out the backspace overstrikes typically used for terminal bolding and underlining, saving the first 30 lines into a clean file named ls_manual_clean.txt.

Review the initial 15 lines of ls_manual_clean.txt with head -n 15 to verify that formatting artifacts were removed.

Inspect ls_manual_clean.txt with the file utility to confirm that the file is classified as plain ASCII text without embedded control codes.

Expanding Tabs to Spaces for Consistent Layouts (col -x)
To demonstrate tab substitution, generate a structured tabular sample containing \t delimiters and write it to sample_tab.txt.

Running col -x expands all hard tabs within sample_tab.txt into regular spaces before writing the stream to sample_space.txt. This standardization prevents tabular misalignment when documents are rendered across editors configured with differing tab stop intervals.

Run od -c on sample_tab.txt to examine the file structure at the byte level.
The breakdown reveals literal \t escape characters demarcating each field.

Examine sample_space.txt using od -c to validate the expansion process.
The dump confirms that every \t delimiter has been translated into a series of standard whitespace bytes.

Preserving Escape Codes and Tuning Buffers (col -p, col -l)
The col -p flag forces the tool to pass ANSI terminal escape sequences—such as color highlight codes—straight through to stdout without filtering. This proves invaluable when processing colored logs where visual markers must remain intact.

Using col -l 256 defines an explicit memory buffer holding up to 256 lines during processing. Allocating larger buffers guarantees consistent output whenever handling massive streams containing complex reverse line feed requests or vertical layout adjustments.

This walkthrough highlighted the core capabilities of col on Ubuntu for stripping terminal artifacts, expanding tabs, and sanitizing text streams. Incorporating these commands into shell pipelines ensures consistent formatting when archiving man pages and parsing complex command outputs.