Monday, September 3, 2012

How do you wrap text file / line / words to fit in specified width in UNIX?

fold -sw {COUNT} {input.txt} > {output.txt}

Where,
-s: break at spaces.
-w: {COUNT} use COUNT as WIDTH columns instead of default 80.

For instance, following command will wrap input.txt at 70 width columns:

fold -sw 70 input.txt > output.txt

No comments :