-
-
Notifications
You must be signed in to change notification settings - Fork 2
Linux expand Guide
Mattscreative edited this page Dec 5, 2025
·
2 revisions
Complete beginner-friendly guide to expand on Linux, covering Arch Linux, CachyOS, and other distributions including converting tabs to spaces, text formatting, and whitespace conversion.
Basic usage:
# Convert tabs to spaces
expand file.txt
# Converts tabs to spacesDefault behavior:
# Default: 8 spaces per tab
expand file.txt
# Converts tabs to 8 spacesSet tab width:
# Custom tab width
expand -t 4 file.txt
# -t = tabs (4 spaces per tab)Multiple stops:
# Multiple tab stops
expand -t 4,8,12 file.txt
# Tab stops at columns 4, 8, 12Uniform width:
# All tabs = 4 spaces
expand -t 4 file.txt
# Every tab becomes 4 spacesVariable stops:
# Variable tab stops
expand -t 4,8,12 file.txt
# Different stops at different columnsModify file:
# In place (GNU extension)
expand -t 4 file.txt > file.txt.tmp
mv file.txt.tmp file.txt
# Or use sponge (from moreutils)
expand -t 4 file.txt | sponge file.txtSave to file:
# Output to file
expand -t 4 file.txt > output.txt
# Saves converted fileCheck installation:
# expand is part of coreutils
# Usually pre-installed
# Check expand
which expandThis guide covered expand usage, tab-to-space conversion, and text formatting for Arch Linux, CachyOS, and other distributions.
- unexpand Guide - Convert spaces to tabs
- sed Guide - Text processing
- Text Processing - Text manipulation
-
expand Documentation:
man expand
This guide covers Arch Linux, CachyOS, and other Linux distributions. For distribution-specific details, refer to your distribution's documentation.