#! /bin/sed -f

# capit_iv.sed -- capitalize words 
# 
# $Id: capit_iv.sed,v 1.2 1998/07/06 20:32:46 cdua Exp $
# Carlos Duarte, 970528

# idea: 
# . grab all first chars of all words into the second part of line
# . convert that chars
# . for each word, replace first char with those
# 
# if line is: "carlos duarte", then
#
# carlos duarte
# \ncarlos duarte\nCD
# Carlos \nduarte\nD
# Carlos Duarte\n\n

h  
s/\([a-zA-Z]\)[a-zA-Z][a-zA-Z]*/\1/g
s/[^a-zA-Z]*//g
y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/
x  
G  
s/^[^a-zA-Z]*/&\
/
t a
:a
s/\n[a-zA-Z]\([a-zA-Z][a-zA-Z]*[^a-zA-Z]*\)\(.*\n\)\(.\)/\3\1\
\2/
t a
P  
d  

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