case command

Shane Ambler FreeBSD at ShaneWare.Biz
Mon Sep 18 03:46:08 UTC 2017


On 18/09/2017 06:02, Polytropon wrote:
> On Sun, 17 Sep 2017 16:07:58 -0400, mfv wrote:
>>> On Sun, 2017-09-17 at 19:37 Polytropon <freebsd at 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.
>>>>
>>>> Is there such a command line command?
>>>
>>> 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'.
> 
> This only works with GNU sed (gsed), to be installed from ports.
> FreeBSD's native sed implementation does not support \L and \U,
> so you'd have to install GNU sed additionally.

Well as we're listing alternate ways -

cat upper.txt | perl -ne 'print lc'

and to reverse it -

perl -ne 'print uc' lower.txt

;)

-- 
FreeBSD - the place to B...Seding Data

Shane Ambler



More information about the freebsd-questions mailing list