column Command Cheatsheet
The column command is a simple but powerful utility used to format a list of data into neat, clean columns. It is most often used with a pipeline (`|`) to make the output of other commands more readable.
Common Usage
| Command | Description |
|---|
cat file.txt | column -t | Reads the content of file.txt and formats it into a table. The -t flag is for table mode, which is the most common use case. |
grep "pattern" files/* | column -t | Finds lines matching a pattern and then uses column to display the results in a formatted table. This is very useful for reading log files or search results. |
ls -1 | column | Formats a list of files (one per line) into multiple columns to better fit the terminal width. |
Key `column` Options
| Option | Description | Example |
|---|
-t | Detects the number of columns and formats the output into a table. This is the most popular option. | ls -l | column -t |
-s [SEPARATOR] | Specifies a custom delimiter for the input. This is useful for parsing files that use separators other than whitespace, such as CSV files. | awk '...' file.csv | column -s, -t |
-c [WIDTH] | Formats the output into a specified width. The command will wrap lines to fit within that width. | cat file.txt | column -c 80 |