Given this file:
$ cat file
alfa bravo charlie delta echo foxtrot golf hotel india juliet kilo lima mike
november oscar papa quebec romeo sierra tango
uniform_victor_whiskey_xray yankee zulu
I would like to hard break at 70, but I would also like to hard refill. I tried
"fold", but it did not refill:
$ fold -w 70 file
alfa bravo charlie delta echo foxtrot golf hotel india juliet kilo lim
a mike
november oscar papa quebec romeo sierra tango
uniform_victor_whiskey_xray yankee zulu
"fmt" will refill, but I could only get it to break on spaces so no guarantee to
wrap on exactly 70:
$ fmt file
alfa bravo charlie delta echo foxtrot golf hotel india juliet
kilo lima mike november oscar papa quebec romeo sierra tango
uniform_victor_whiskey_xray yankee zulu
I tried "pr" but it seems to just truncate the line without wrapping:
$ pr -t -W 70 file
alfa bravo charlie delta echo foxtrot golf hotel india juliet kilo lim
november oscar papa quebec romeo sierra tango
uniform_victor_whiskey_xray yankee zulu
Maybe these commands have some option I am missing, or maybe Awk or Sed
solution. I would prefer to avoid heavier solutions (Perl PHP Ruby).
Asked by Zombo
(1 rep)
Mar 3, 2018, 05:02 AM
Last activity: Oct 10, 2018, 11:10 PM
Last activity: Oct 10, 2018, 11:10 PM