Overview
column is useful for transforming text data into a neat column format. Especially when using the -t option for table mode, each field of the data is automatically aligned, making it easy to read.
Key Features
- Automatic column width adjustment (-t)
- Specify custom delimiter (-s)
- Output with specified width (-c)
- Row-wise or column-wise filling
Key Options
The main options for the column command control the output format and data processing.
Output Formatting
Data Processing
Generated command:
Try combining the commands.
Description:
`column` Executes the command.
Combine the above options to virtually execute commands with AI.
Usage Examples
Learn how to use the column command to neatly align various text data.
Sort ls -l output into a table
ls -l | column -t
Sort the output of the ls -l command into a clean table format using column -t.
Sort /etc/passwd file using colon (:) delimiter
cat /etc/passwd | column -s ':' -t
The /etc/passwd file uses colons (:) to separate fields. Sort it into a table format with column -s : -t.
Fill numbers column-wise
seq 10 | column -x
Sort and output numbers from 1 to 10 in a column-wise manner (-x).
Output with a specific width
echo "apple banana cherry date elderberry fig grape" | column -c 20
Format the input text into columns with a maximum width of 20 characters.
Tips & Notes
Useful tips and considerations when using the column command.
Combining with Other Commands
column is very useful when used in conjunction with other commands like `ls`, `ps`, `df`, `cat`, by piping their output through it.
- `ps aux | column -t`: Neatly sort process list
- `df -h | column -t`: Nicely sort disk usage information
Importance of Specifying Delimiters
If the delimiter for your input data is not whitespace (e.g., the colon in `/etc/passwd`), you must specify the correct delimiter using the `-s` option to get proper table output.