Date: Sun, 17 Sep 2017 16:07:58 -0400 From: mfv <mfv@bway.net> To: freebsd-questions@freebsd.org Cc: Polytropon <freebsd@edvax.de> 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>
next in thread | previous in thread | raw e-mail | index | archive | help
> On Sun, 2017-09-17 at 19:37 Polytropon <freebsd@edvax.de> 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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20170917160758.18b6000e>