Skip to content

Commit c861b27

Browse files
sahilshingate01bobbyiliev
authored andcommitted
docs: add column command documentation
1 parent 557fdf5 commit c861b27

File tree

2 files changed

+68
-0
lines changed

2 files changed

+68
-0
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -593,6 +593,7 @@ Feel free to add new topics in case that you don't find one that you like from t
593593
### File Commands
594594

595595
- [cat/tac](ebook/en/content/003-the-cat-tac-command.md) - concatenate and print files
596+
- [column](ebook/en/content/161-the-column-command.md) - format text into columns
596597
- [diff/sdiff](ebook/en/content/062-the-diff-sdiff-command.md) - compare files line by line
597598
- [find](ebook/en/content/102-the-find-command.md) - search for files
598599
- [grep](ebook/en/content/107-the-grep-command.md) - file pattern matcher
@@ -922,6 +923,7 @@ Feel free to add new topics in case that you don't find one that you like from t
922923
- [158-the-tty-command.md](ebook/en/content/158-the-tty-command.md)
923924
- [159-the-lspci-command.md](ebook/en/content/159-the-lspci-command.md)
924925
- [160-the-cfdisk-command.md](ebook/en/content/160-the-cfdisk-command.md)
926+
- [161-the-column-command.md](ebook/en/content/161-the-column-command.md)
925927

926928
# 🔗Links
927929

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
# The `column` Command
2+
3+
The `column` command is used to format its input into multiple columns. It's particularly useful for making text-based tables and improving the readability of command output.
4+
5+
## Command Syntax
6+
```bash
7+
column [options] [file]...
8+
```
9+
10+
## Command Options
11+
- `-t`: Determine the number of columns automatically and create a table
12+
- `-s`: Specify the column delimiter (default is whitespace)
13+
- `-n`: Don't merge multiple adjacent delimiters
14+
- `-c`: Output in column format with specified width
15+
- `-x`: Fill columns before rows
16+
- `-L`: Align all entries to the left
17+
- `-R`: Align all entries to the right
18+
- `-o`: Specify column separator for table output
19+
20+
## Examples
21+
22+
1. Basic Column Formatting
23+
```bash
24+
# Create a simple list and format it into columns
25+
ls | column
26+
```
27+
28+
2. Creating a Table from Delimited Data
29+
```bash
30+
# Format /etc/passwd entries into a neat table
31+
cut -d: -f1,6,7 /etc/passwd | column -t -s:
32+
```
33+
34+
3. Formatting Command Output
35+
```bash
36+
# Display mount information in a clean tabular format
37+
mount | column -t
38+
```
39+
40+
4. Custom Column Separator
41+
```bash
42+
# Format CSV data with custom separator
43+
echo "Name,Age,City\nJohn,25,NYC\nJane,30,LA" | column -t -s,
44+
```
45+
46+
5. Left-aligned Table
47+
```bash
48+
# Create a left-aligned table from space-separated data
49+
ps aux | head -n 5 | column -t -L
50+
```
51+
52+
## Additional Information
53+
- The `column` command is part of the `util-linux` package
54+
- It's particularly useful in shell scripts for formatting output
55+
- Can handle both file input and standard input (stdin)
56+
- Works well with other text processing commands like `cut`, `sort`, and `grep`
57+
58+
## See Also
59+
- [`cut`](098-the-cut-command.md) - remove sections from files
60+
- [`sort`](059-the-sort-command.md) - sort lines of text files
61+
- [`paste`](060-the-paste-command.md) - merge lines of files
62+
- [`tr`](119-the-tr-command.md) - translate or delete characters
63+
64+
## Further Reading
65+
- `man column` - manual page for the column command
66+
- [GNU Coreutils](https://www.gnu.org/software/coreutils/)

0 commit comments

Comments
 (0)