---
title: "Mastering the Linux column Command: A Comprehensive Guide with Examples"
description: "Stop squinting at misaligned terminal output. The often-overlooked column command turns messy text into clean tables — with headers, hidden columns, reordering, even JSON — in a single pipe."
url: https://akemara.com/en/blog/linux-column-command/
lang: en
author: "Ahmed K Emara"
date: 2025-01-15
lastmod: 2025-01-15
section: blog
tags: ["Linux","CLI","DevOps"]
translations:
  ar: https://akemara.com/ar/blog/linux-column-command/
---

# Mastering the Linux column Command: A Comprehensive Guide with Examples

> Stop squinting at misaligned terminal output. The often-overlooked column command turns messy text into clean tables — with headers, hidden columns, reordering, even JSON — in a single pipe.

The `column` command in Linux is a powerful yet often overlooked tool for formatting text output into columns. It is particularly useful for making messy or unstructured data more readable by aligning it into neat tables. Whether you're a system administrator, developer, or just a Linux enthusiast, mastering the `column` command can save you time and make your work more efficient.

In this article, we’ll explore the `column` command in detail, covering all its use cases with practical examples. By the end, you'll be able to use `column` like a pro!

## 1. Introduction to the column Command

The `column` command is part of the `util-linux` package and is available on most Linux distributions. It is designed to format text into columns, making it easier to read and analyze. It works with both piped input and files, and it supports various options for customizing the output.

## 2. Basic Usage

The simplest way to use `column` is to pipe text into it. By default, it formats the input into columns:

```bash
$ echo -e "Name Age\nJohn 25\nJane 30\nDoe 22" | column -t
Name  Age
John  25
Jane  30
Doe   22
```

- The `echo` command generates a list of names and ages.
- The `column` command formats the output into two columns.

## 3. Filling Rows Before Columns (-x)

By default, `column` fills columns before rows. However, you can use the `-x` option to fill rows first:

```bash
$ echo -e "Name Age\nJohn 25\nJane 30\nDoe 22" | column -x
Name Age John 25  Jane 30  Doe 22
```

The `-x` option ensures that rows are filled before columns.

## 4. Using column with Files

Instead of piping input, you can directly pass a file to `column`:

```bash
$ column file.txt
```

- This formats the contents of `file.txt` into columns.

## 5. Formatting find Command Output

The `column` command is particularly useful for cleaning up the output of commands like `find`:

```bash
$ find /usr/share/fonts -name "*.otf" | column
```

- This lists all `.otf` files in `/usr/share/fonts` and formats the output into columns.

## 6. Table Mode (-t)

The `-t` option enables table mode, which is ideal for formatting structured data:

```bash
$ cat /etc/passwd | column -t -s ":"
```

- This formats the `/etc/passwd` file into a table, using `:` as the delimiter.

## 7. Adding Column Headers (-N)

The `-N` option allows you to add column headers to the output:

```bash
$ cat /etc/passwd | column -t -s ":" -N "USERNAME,PW,UID,GID,COMMENT,HOME,INTERPRETER"
```

- This formats `/etc/passwd` into a table with custom column headers.

## 8. Hiding Columns (-H)

The `-H` option allows you to hide specific columns:

```bash
$ cat /etc/passwd | column -t -s ":" -N "USERNAME,PW,UID,GID,COMMENT,HOME,INTERPRETER" -H "PW"
```

- This hides the `PW` (password) column from the output.

## 9. Reordering Columns (-O)

The `-O` option allows you to reorder columns:

```bash
$ cat /etc/passwd | column -t -s ":" -N "USERNAME,PW,UID,GID,COMMENT,HOME,INTERPRETER" -O "USERNAME,UID,GID,COMMENT,HOME,INTERPRETER"
```

- This reorders the columns, removing the `PW` column.

## 10. JSON Output (-J)

The `-J` option outputs the data in JSON format:

```bash
$ cat /etc/passwd | column -t -s ":" -N "USERNAME,PW,UID,GID,COMMENT,HOME,INTERPRETER" -J -n "users"
```

- This converts the `/etc/passwd` data into a JSON object named `users`.

## 11. Combining Options for Advanced Formatting

You can combine multiple options for more advanced formatting:

```bash
$ cat /etc/passwd | column -t -s ":" -N "USERNAME,PW,UID,GID,COMMENT,HOME,INTERPRETER" -H "PW" -O "USERNAME,UID,GID,COMMENT,HOME,INTERPRETER" -J -n "users"
```

**This command:**

- Formats `/etc/passwd` into a table.
- Adds column headers.
- Hides the `PW` column.
- Reorders the columns.
- Outputs the result as JSON.

## 12. Conclusion

The `column` command is a versatile tool for formatting text output into columns, making it easier to read and analyze. Whether you're working with command output or files, `column` can help you present data in a clean, tabular format.

## Key Takeaways:

- Use `-t` for table mode.
- Use `-s` to specify a delimiter.
- Use `-N` to add column headers.
- Use `-H` to hide columns.
- Use `-O` to reorder columns.
- Use `-J` for JSON output.

For more advanced data manipulation, consider using tools like `awk`. However, for quick and easy formatting, `column` is an indispensable tool in your Linux toolkit.

## Final Thoughts

The `column` command is a simple yet powerful way to organize and present data. By mastering its options, you can save time and make your work more efficient. Whether you're a system administrator, developer, or just a Linux enthusiast, `column` is a tool you'll want to keep handy.

Happy formatting! 🚀
