Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

4
  • 2
    +1, but perhaps better written as echo $MYSTRING | fold -w 30, since the -30 syntax doesn't appear in the fold manpage? Commented Jan 3, 2013 at 23:14
  • 5
    For posterity, there is also fmt. The difference between fold and fmt is that fold will wrap at the fixed width, even splitting words and may begin lines with blanks. While fmt will wrap near or under the width, it will not split words, lines will not begin with blanks and short lines may be joined. Commented Jan 3, 2013 at 23:15
  • 5
    fold appears to have similar behavior to fmt when the -s option is used. Commented Jan 3, 2013 at 23:16
  • funny, i used -w option but it split it by char. Commented Jan 4, 2013 at 2:26