Linux fold command
Updated: 05/04/2019 by Computer Hope
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
-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.
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.
Related commands
cut — Remove or "cut out" sections of each line of a file or files.
pr — Format a text file for printing.