Docs / Linux Basics / How to Use column, cut, and paste for Text Formatting

How to Use column, cut, and paste for Text Formatting

By Admin · Mar 15, 2026 · Updated Apr 24, 2026 · 164 views · 2 min read

Linux provides powerful text manipulation tools that help you process command output, CSV files, and log data. The column, cut, and paste commands are simple but incredibly useful for formatting and extracting data on the command line.

cut: Extract Fields from Text

# Extract specific fields from delimited text
# -d sets delimiter, -f selects fields

# Get usernames from /etc/passwd (field 1, colon-delimited)
cut -d: -f1 /etc/passwd

# Get username and shell (fields 1 and 7)
cut -d: -f1,7 /etc/passwd

# Get fields 1 through 3
cut -d: -f1-3 /etc/passwd

# Extract from CSV files
cut -d, -f2,4 data.csv

# Extract by character position
cut -c1-10 /var/log/syslog    # First 10 characters of each line
cut -c5- /var/log/syslog      # From character 5 to end

# Extract IPs from access log
cut -d" " -f1 /var/log/nginx/access.log | sort | uniq -c | sort -rn | head

column: Format Text into Columns

# Make tab-separated output pretty
mount | column -t

# Format with a custom delimiter
cat /etc/passwd | column -t -s:

# Format CSV into a readable table
column -t -s, < data.csv

# Practical examples:
# Make df output more readable
df -h | column -t

# Format process list
ps -eo pid,user,pcpu,pmem,comm | column -t

# Create a table from command output
echo -e "Name	Size	Date
file1	100K	2025-01-15
file2	200K	2025-01-16" | column -t

paste: Merge Lines from Files

# Merge corresponding lines from two files side by side
paste file1.txt file2.txt

# Use a custom delimiter
paste -d, file1.txt file2.txt

# Convert a column into a comma-separated row
cat list.txt | paste -sd,
# Input:       Output:
# apple        apple,banana,cherry
# banana
# cherry

# Merge every N lines into one
cat data.txt | paste - - -    # Every 3 lines become 1 (tab-separated)

# Practical: Create CSV from separate columns
paste -d, names.txt ages.txt cities.txt > combined.csv

Combining Tools

# Extract and format specific columns from a log
cut -d" " -f1,7,9 /var/log/nginx/access.log | column -t | head

# Create a user report
paste -d:         

Was this article helpful?