On Unix-like operating systems, the fold command wraps each line of input text to fit a specified line width.

This page covers the GNU/Linux version of fold.

Syntax

fold [OPTION]… [FILE]…

Options

If no FILE is specified, fold reads from standard input.

  • Syntax
  • Examples
  • Related commands
  • Linux commands help

Examples

fold -w5 myfile.txt > newfile.txt

Wraps the lines of myfile.txt to a width of 5 characters, and writes the output to newfile.txt.

cut — Remove or “cut out” sections of each line of a file or files.pr — Format a text file for printing.