I am trying to make a sed script that will make the first letter of each
molly w. bolt 334-78-5443
walter q. bugg 984-49-0032
noah p. way 887-12-0921
So, I want it to look like this:
molly w. bolt 334-78-5443
walter q. bugg 984-49-0032
noah p. way 887-12-0921
So far I have the following script, but it will use only the first two words that it meets, i.e. making him Molly V. a bolt. I cannot figure out how to change the script to get the name in uppercase. What do I need to add?
h
s/\(.\).*/\1/
y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/
G
s/\(.\)\n\(.\)\(.*\)/\1\3/
/ [a-z]/{
h
s/\([A-Z][a-z]* \)\([a-z]\).*/\2/
y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/
G
s/\(.\)\n\([A-Z][a-z]* \)\(.\)\(.*\)/\2\1\4/
}
Joe source
share