Text and processing

The fold command

Wraps long lines into chunks of a given width. Useful to fit text to a screen or page.

Syntax

fold [-w N] [-s] [archivo]

Most useful options

-w NMaximum width of each line
-sBreaks at spaces instead of mid-word

Copy-ready examples

$ printf 'abcdefghij\n' | fold -w 4Break every 4 characters

You can try them in the browser terminal: it does not touch your computer.

Typical mistakes

  • Without -s it can split words in half.

Related commands

FAQ

Difference from fmt?

fold cuts at a fixed width; fmt reflows the words to fill the width.

Learn to actually use it

The basic Linux course takes you from zero to console fluency with 24 self-grading lessons.

Start the free course