fold lines (POSIX)
fold [-bs] [-w width] [file...]
Fold the file myfile.txt to a maximum line width of 80 characters, making the line breaks on the last word boundary (white space) before the width was exceeded and write the results to the standard output:
fold -s myfile.txt
Fold the file myfile.txt to a width of 40 characters, and treat all characters except newline as occupying one character (byte) position and write the results to the standard output:
fold -bw40 myfile.txt
The fold filter folds lines in files by breaking up lines that have a width in excess of 80 or, if specified, the width in the command-line -w option. Lines are folded by the insertion of a newline character. All output is written to the standard output.
In all cases, the current count of line width is reset to zero when a newline character is encountered in the input. In addition, when the -b option is not specified, the following characters have a special meaning when encountered in the input:
If no files are specified on the command line, fold reads lines to be folded from the standard input until EOF is reached.
fold writes all folded output from all input files to the standard output.
If an error occurs, a diagnostic message will be written to the standard error.
fold will read lines from the text files specified on the command line. If the -b is specified, the input files need not be text files.