shell script to cap first letter?

Gary Kline kline at thought.org
Sun Mar 21 20:24:10 UTC 2010


On Sun, Mar 21, 2010 at 10:16:22AM -0400, b. f. wrote:
> >i'm wondering if there is a script that i could run my plaintext
> >files thru that would capitalize thef first letter of each
> >sentence [[ assuming the character wasn't already a cap!]]
> >
> >more and more, in recent years, i have posted questions or
> >written things that have been sloppily or casually hacked
> >together in all lower case.  this filter would have to determine
> >what was and was not a sentence.  or a sentence fragment.
> >[ai]spell can catch "i've" and suggest "I've", etc.
> 
> You're asking a lot from a simple filter if you want it to
> discriminate between uses of "." to terminate a sentence, and other
> uses of "." that do not require the following word to be capitalized,
> such as the use of "." in abbreviations -- a lot of fairly
> sophisticated spelling and grammar checkers can fail to do this
> reliably.  But if you want a naive filter you could use textproc/gsed,
> with the /U GNU extension (our BSD sed(1) doesn't understand it),
> e.g.:
> 
> gsed -e 's|\(\.[.[:space:].]\)\([a-z]\)|\1\U\2|g'
> 
> or you could use BSD sed(1), together with a more cumbersome
> capitalization script, like the cflword[12345].sed scripts at:
> 
> http://sed.sourceforge.net/grabbag/scripts/#txfo
> 
> Or you could use Perl.  Or awk(1). Or script a [non-]interactive call
> to a more sophisticated spelling or grammar checker. Or roll your own.
>  For questions like this, try searching the web first.
> 
> b.

	given the sheer i.q. power ofthis list, i almost always ask 
	here first rather thsan hunting for something this obscure.
	thanks for the url, tho.  

	i'm pretty sure than *someone* has hacked every imagineable 
	function in at least this universe.  too bad that there are
	no web sites that have a library of them.  

	gary


-- 
 Gary Kline  kline at thought.org  http://www.thought.org  Public Service Unix
        http://jottings.thought.org   http://transfinite.thought.org
    The 7.79a release of Jottings: http://jottings.thought.org/index.php



More information about the freebsd-questions mailing list