Linux fold command

Updated: 06/16/2017 by Computer Hope

About fold

fold wraps each line of input text to fit a specified line width.

fold syntax

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 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.