Wrap Text With fold
Break long lines at a width, optionally at word boundaries.
Run fold -s -w 80 file to wrap each line at 80 columns on spaces.
01Command
Command
$ fold -s -w 80 long.txt02What it does
fold inserts newlines at a chosen width, and -s prefers spaces so words are not split, which is ideal for formatting plain-text reports or commit messages. It is a small, reliable filter for textual pipelines.
03Risk
!Warning: It counts columns, not visual width; wide CJK characters and tabs can shift the actual display.
04Undo
✓No undo needed — this command does not change persistent state.
05Sources
- fold.1.en.html manual page (Debian bookworm)Evidence: Documents fold, which wraps input lines to a specified width.
Last verified: 2026-10-13 · Category: Developer