2

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?

1 Answer 1

6

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.

1
  • 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, 2012 at 15:35

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .