Script and Comments
Script1
[ 1] /^$/b
[ 2] :loop
[ 3] /^.\{31\}/!{
[ 4] /\n$/b
[ 5] $q
[ 6] N
[ 7] b loop
[ 8] }
[ 9] s/\n/ /g
[10] s/^\(.\{1,30\}\) /\1\n /
[11] s/^\(.\{1,29\}\)\n /\1 \n/
[12] /\n/!s/ /\n /
[13] P
[14] D
Comments
  1. Paragraphs are separated by empty lines.
  2. 'Pattern Space' is abbreviated to 'PS'.
  3. When a new cycle brings into PS an empty line or one consists of only blanks, we will pay no attention to it but just print it out.
  4. The loop consists of Steps [3] thru [8] will keep joining lines of the same paragraph unless the PS contains more than 30 characters.
  5. Once the PS contains more than 30 characters,
    • Step [9] will replace every newline char with a space.
    • Step [10] and [11] will insert newline char at the best splitting-point.
    • After Step [10], if PS does not contain any newline character, this implies that PS begins with a string longer than 30 chars.
    • Step [11] and [12] will print-out-then-delete the first line of PS. Command 'D' will make sed jump back to Step [1].
Raw Input
This is a test file to see whether the proposed
sed script can correctly format this file based on paragraphs.
Every line of the output consists of no more than
30 characters.
Linux becomes popular as time passes. I first met Linux
in August, 1993. At that time, Linux was not user-friendly
at all. Although it has GUI environment, but it is not
fantastic at all.
Nowadays, there are several projects developing GUI programs
on Linux system: GNOME and KDE. They provides many useful
and good-looking tools.
Desired Output
This is a test file to see 
whether the proposed sed 
script can correctly format 
this file based on paragraphs.
 Every line of the output 
consists of no more than 30 
characters.
Linux becomes popular as time 
passes. I first met Linux in 
August, 1993. At that time, 
Linux was not user-friendly at
 all. Although it has GUI 
environment, but it is not 
fantastic at all.
Nowadays, there are several 
projects developing GUI 
programs on Linux system: 
GNOME and KDE. They provides 
many useful and good-looking 
tools.