Name: fold Description: wrap each input line to fit specified width Author: Clinton Pierce, firstname.lastname@example.org Author: Tom Christiansen, email@example.com License: perl
fold - wrap each input line to fit specified width
fold [-bs] [-w width] [file ...]
The fold command reads lines from the specified files (or standard input if none are specified) and writes them to the standard output with newlines inserted into lines longer than the specified column width.
The default column width is 80,
but this may be overridden using the -w flag.
For historical reasons,
the width may be specified directly,
omitting the -w.
The -s flag causes breaks to occur after whitespace rather than in the middle of a word. This produces a ragged right edge, but is much nicer to look at.
The -b flag makes the program ignore embedded backspaces, tabs, and carriage returns when deciding where to split. This makes it run about thirty times faster. You might want to get used to using -b.
Current locale settings will be honored in determining what is meant by "whitespace" and "word characters".
POSIX 1003.2 states that a newline will never be inserted immediately before or after a backspace or a carriage return, but this is not checked for.
Clinton Pierce and Tom Christiansen.
This code is freely modifiable and freely redistributable under Perl's Artistic License.