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-wordCopy-ready examples
$ printf 'abcdefghij\n' | fold -w 4Break every 4 charactersYou can try them in the browser terminal: it does not touch your computer.
Typical mistakes
- Without -s it can split words in half.
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