Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I would need to print the contents of a file (e.g., cat $file), but wrap output at a given column width (let's say 80 cols), independently of terminal width.

Is there something in the "standard" Unix arsenal that would give me this functionality?

share|improve this question
up vote 4 down vote accepted

The basic tool for doing this is fold(1). For example,

fold -s -w 80 $file

will fold the lines in $file to fit within 80 columns and break lines at spaces.

share|improve this answer
    
I knew there had to be something like that, but couldn't find it... BTW, 80 columns are default already, so a simple | fold works perfectly for me. Thanks! – DevSolar Sep 13 '12 at 15:35

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.