From owner-freebsd-questions@freebsd.org Sun Sep 17 20:08:07 2017 Return-Path: Delivered-To: freebsd-questions@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 5E9DBE01B9A for ; Sun, 17 Sep 2017 20:08:07 +0000 (UTC) (envelope-from mfv@bway.net) Received: from smtp1.bway.net (smtp1.v6.bway.net [IPv6:2607:d300:1::27]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 3DD616C23C for ; Sun, 17 Sep 2017 20:08:07 +0000 (UTC) (envelope-from mfv@bway.net) Received: from gecko4 (host-216-220-115-171.dsl.bway.net [216.220.115.171]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: m1316v@bway.net) by smtp1.bway.net (Postfix) with ESMTPSA id 076C895861; Sun, 17 Sep 2017 16:07:58 -0400 (EDT) Date: Sun, 17 Sep 2017 16:07:58 -0400 From: mfv To: freebsd-questions@freebsd.org Cc: Polytropon Subject: Re: case command Message-ID: <20170917160758.18b6000e@gecko4> In-Reply-To: <20170917193722.7d2ecbe3.freebsd@edvax.de> References: <59BE89E1.3050209@gmail.com> <20170917193722.7d2ecbe3.freebsd@edvax.de> Reply-To: mfv@bway.net MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 17 Sep 2017 20:08:07 -0000 > On Sun, 2017-09-17 at 19:37 Polytropon wrote: > >On Sun, 17 Sep 2017 10:42:41 -0400, Ernie Luzar wrote: >> Looking for a system command that a I can pip a file through to >> change all uppercase content to lower case. >>=20 >> Is there such a command line command? =20 > >Several ones. One is to use tr: > > ... | tr '[A-Z]' '[a-z]' | ... > >Or with character classes: > > ... | tr '[:upper:]' '[:lower:] | ... > >You can also use awk for this task: > > ... | awk '{ print tolower($0) }' | ... > >You can use this within the awk portion of your script, too. > >Or shortened: > > ... | awk '{ print tolower }' | ... > >But keep in mind: Things like german Umlauts usually won't >be processed correctly. > >Those are a few possible solutions. There are more. ;-) > > > Hello, Yes, Indeed. Here is an alternative using gsed: gsed -e 's/(.*)/\L\1/' < input | ... To convert from lower case to upper case, change '\L' to '\U'. As gsed operates on one line at a time it will not be as fast as other solutions but has the merit of working on very large files when memory is an issue. It is also able to convert some Unicode, at least some of the Latin-1 Supplements and Latin Extended-A. If conversions are needed for a particular language not already covered by gsed then the y-command could be added. For example: y/=C3=82=C3=83=C3=84=C3=85=C3=81/=C3=A2=C3=A3=C3=A4=C3=A5=C3=A1/ This is an artificial example. Since gsed already handles this conversion the y-command would not be needed. I'm not well versed in Unicode except for a few Latin code pages and gsed works as expected for those pages. Cheers ... Marek