Linux Comm Column
[ Linux Command Manual](#)
* * *
`column` is a practical command-line tool in Linux systems, used to format input text into multi-column display. It can reorganize messy text data into neat table format, greatly improving readability.
**Typical Application Scenarios**:
* Formatting command output (such as `ls`, `ps`, etc.)
* Organizing CSV or TSV data
* Creating simple terminal tables
* Aligning log file content
* * *
## Basic Syntax
column
If no filename is specified, `column` reads data from standard input.
* * *
## Common Options and Parameters
| Option | Description |
| --- | --- |
| `-t` | Automatically recognize input delimiters and create a table |
| `-s sep` | Specify custom column delimiter (default is whitespace) |
| `-c width` | Set total output width (number of characters) |
| `-x` | Fill rows before columns (default is columns before rows) |
| `-o sep` | Specify output column delimiter (default is two spaces) |
| `-N names` | Specify names for columns (comma-separated) |
| `-n` | Do not merge multiple consecutive delimiters |
* * *
## Usage Examples
### Basic Table Formatting
## Example
$ echo-e"Name Age GendernAlice 25 FnBob 30 MnCharlie 22 M"| column -t
Name Age Gender
Alice 25 F
Bob 30 M
Charlie 22 M
### Processing CSV Data
## Example
$ echo-e"ID,Name,Departmentn101,Alice,Salesn102,Bob,IT"| column -s, -t
ID Name Department
101 Alice Sales
102 Bob IT
### Custom Output Delimiter
## Example
$ echo-e"1 2 3n4 5 6"| column -t-o" | "
1|2|3
4|5|6
### Combining with Other Commands
## Example
$ ls-l|head-5| column -t
total 48
drwxr-xr-x 2 user user 4096 Jan 10 09:30 Desktop
drwxr-xr-x 2 user user 4096 Jan 10 09:30 Documents
drwxr-xr-x 2 user user 4096 Jan 10 09:30 Downloads
* * *
## Advanced Usage
### Handling Irregular Data
## Example
$ echo-e"Item:Price:StocknApple:1.2:50nOrange:0.8:30"| column -s: -t
Item Price Stock
Apple 1.2 50
Orange 0.8 30
### Specifying Column Names
## Example
$ echo-e"Alice 25nBob 30"| column -N"Name,Age"-t
Name Age
Alice 25
Bob 30
### Controlling Output Width
## Example
$ echo-e"1 2 3 4 5n6 7 8 9 10"| column -c 30-t
1 3 5 7 9
2 4 6 8 10
* * *
## Notes
1. **Delimiter Handling**: By default, `column` treats multiple consecutive whitespace characters as a single delimiter. Use the `-n` option to disable this behavior
2. **Special Characters**: If data contains spaces or tabs as delimiters, it is recommended to explicitly specify the delimiter
3. **Performance Considerations**: When processing large files, `column` may require significant memory
4. **Alignment**: All columns are left-aligned by default; direct alignment specification is currently not supported
* * *
## Alternative Comparison
| Tool | Advantages | Disadvantages |
| --- | --- | --- |
| `column` | Simple to use, built into Linux | Relatively basic functionality |
| `awk` | Highly flexible, powerful | Complex syntax |
| `pr` | Supports pagination and column control | Complex options |
| `paste` | Suitable for merging file columns | Limited formatting capabilities |
* * *
## Practice Exercises
1. Format the first 5 lines of your `/etc/passwd` file into a table display (hint: use `:` as the delimiter)
2. Try using the `column` command to organize your process list (`ps aux` output)
3. Create a text file containing three columns of data, and experiment with the `-s` option using different delimiters
## Example
# Exercise 1 Example Solution
head-5/etc/passwd| column -s: -t
By mastering the `column` command, you can easily transform messy text data into readable table format, which is very practical in daily system administration and data processing.
* * Linux Command Manual](#)
YouTip