Text Processing

fold

Wrap each input line to fit in specified width.

Synopsis

syntax
fold [OPTION]... [FILE]...

Examples

Wrap lines at 60 characters
fold -w 60 file.txt
Wrap at spaces within 72 columns
fold -s -w 72 article.txt
Wrap PATH for readability
echo $PATH | fold -s -w 40

Common options

FlagDescription
-wWrap at specified width (default 80)
-sBreak at spaces
-bCount bytes instead of columns

About fold

The `fold` command wrap each input line to fit in specified width. Text processing commands transform, format, and generate text output.

Linux's philosophy of small composable tools shines here — these commands are designed to be piped together to build complex text-processing workflows. They are indispensable for scripting, log analysis, and data transformation tasks.

The command accepts 3 commonly used flags shown above, though the full set of options is available in the man page (`man fold`). The 3 examples on this page cover typical real-world usage patterns that you can copy and adapt for your own workflows.

Related commands

More Text Processing Commands

Other commands in the Text Processing category

Related tools