#! /bin/sed -f 

# fmt.sed -- format text such as each line gets below 40 chars
# $Id: fmt.sed,v 1.1 1998/05/28 04:21:33 cdua Exp $ 
# Carlos Duarte, 980528

:a
/^.\{40\}/ !{
    $ q
    N
    s/ *\n */ /
    b a
}  
s/^.\{40\}/&\
/
s/^\(.*\) \(.*\)\n/\1\
\2/
P  
s/^.*\n//
b a

### colorized by sedsed, a debugger and code formatter for sed scripts
### original script: http://sed.sf.net/grabbag/scripts/fmt.sed