Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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
add comment

1 Answer 1

up vote 3 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
add comment

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.