word wrap command line tool

I just couldn’t find one, so I ended up using this line:

cat <textfile> | perl -e 'use Text::Wrap;$Text::Wrap::columns=70;
while(<>) {print wrap("","",$_)}'

2 thoughts on “word wrap command line tool

  1. @Kevin: Thanks. That’s what I was looking for. But very hard to find if you search for “word wrap”.
    fmt -s -w70 does almost the same as this perl line. The fine difference is, that fmt doesn’t split words, that are longer than the line width.

Leave a Reply

Your email address will not be published. Required fields are marked *