Wrap Text With fold

Break long lines at a width, optionally at word boundaries.

LinuxtextcliLow risk
Run fold -s -w 80 file to wrap each line at 80 columns on spaces.

01Command

Command
$ fold -s -w 80 long.txt

02What 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

RiskLow risk
RequirementsPreinstalled on Linux (GNU coreutils)
!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

Last verified: 2026-10-13 · Category: Developer

06Related solutions