[PLUG] Changing Case in a List of Names

Jason Dagit dagitj at gmail.com
Thu Apr 16 02:06:04 UTC 2009


On Wed, Apr 15, 2009 at 5:57 PM, Rich Shepard <rshepard at appl-ecosys.com> wrote:
>   I have a list of company names all in upper case; one per line. Can I use
> a combination of sed, tr, and other tools to automate converting them all to
> mixed case (i.e., initial letter uppercase, all others lower case)? There
> must be a shell script already written to do this, but not in the reference
> books I have.

Rich,

I see else where in this thread that you have your solution but let me
propose another way to arrive at a solution.

You can use emacs to interactively record a macro for this purpose.
In fact, since I prefer programming by demonstration for these sorts
of tasks I usually use emacs and teach it what to do.

Open the file in question.  Then type C-x C-(, this will begin
recording a macro.  Then hit C-a for beginning of line, M-c, or M-x
capitalize-word, then hit C-n for the next line.  Now type C-x C-) to
end the macro.  You can now repeat this macro with C-u N C-x C-e,
where N is the number of times you want to execute the macro.  Or just
C-x C-e if you want to run the macro once.  After you memorize the
basic dance of creating a line by line macro the only hard part is
figuring out what commands to do in the middle, M-x capitalize-word in
this case.  But, the nice part is you get a fairly general formula for
text manipulation that takes just a few minutes to apply -- and you
don't have to learn a programming language if you don't want to.

I hope you find this useful in the future.
Jason



More information about the PLUG mailing list