Linux fold command

Updated: 05/04/2019 by Computer Hope
fold command

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

This document covers the GNU/Linux version of fold.


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


-b, --bytes count bytes rather than columns.
-s, --spaces break at spaces.
-n, -wn, --width=n use n columns instead of the default of 80.
--help Display a help message and exit.
--version Display version information and exit.

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


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.