From owner-freebsd-questions@FreeBSD.ORG Sun Mar 21 14:16:25 2010 Return-Path: Delivered-To: freebsd-questions@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 5ECD11065672 for ; Sun, 21 Mar 2010 14:16:25 +0000 (UTC) (envelope-from bf1783@googlemail.com) Received: from mail-ww0-f54.google.com (mail-ww0-f54.google.com [74.125.82.54]) by mx1.freebsd.org (Postfix) with ESMTP id EDDA08FC25 for ; Sun, 21 Mar 2010 14:16:24 +0000 (UTC) Received: by wwb18 with SMTP id 18so2842278wwb.13 for ; Sun, 21 Mar 2010 07:16:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=gamma; h=domainkey-signature:mime-version:received:reply-to:date:message-id :subject:from:to:cc:content-type; bh=y2YlQ6V6atRaS0w/kQvAFWy4fBwOT1+dz12OCb8ekOs=; b=R9eJHwHD3g7BQu7j0tz9SzmezDepNKNlf19zDwmCXaT1ULt8xXUkg9aFk3jYqPqGQJ W+9INKwOsUbzDFTNZUVXXjokE/c3/O5kHy/JDACS9f3vCWYuLt+KFsteseeTQiu12amV +9xj7UnM8iegani/APDJCkbL/4EDA67xQdZnE= DomainKey-Signature: a=rsa-sha1; c=nofws; d=googlemail.com; s=gamma; h=mime-version:reply-to:date:message-id:subject:from:to:cc :content-type; b=r3JNXPHlpQ2zsboQasc28N8WDNzCSn5A46DFKTtmAazr19DEIw3OVmz9Uo3woIZG4+ GZpqCYxds2+xhJXBVhKvjP7olDBCPYjbWdNvDtoJxPRGkL60jK/aCtd9b2UOrKv5Gf7D 5vBzkm7uaz7p7qWvSuM/tCKvbBCmT3yqjAq5Q= MIME-Version: 1.0 Received: by 10.216.87.83 with SMTP id x61mr720611wee.7.1269180983242; Sun, 21 Mar 2010 07:16:23 -0700 (PDT) Date: Sun, 21 Mar 2010 10:16:22 -0400 Message-ID: From: "b. f." To: Gary Kline Content-Type: text/plain; charset=ISO-8859-1 Cc: freebsd-questions@FreeBSD.org Subject: Re: shell script to cap first letter? X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: bf1783@gmail.com List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 21 Mar 2010 14:16:25 -0000 >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.