Re: case command

classic Classic list List threaded Threaded
12 messages Options
Reply | Threaded
Open this post in threaded view
|

Re: case command

Tim Daneliuk
On 09/17/2017 09:42 AM, 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?
> _______________________________________________
> [hidden email] mailing list
> https://lists.freebsd.org/mailman/listinfo/freebsd-questions
> To unsubscribe, send any mail to
> "[hidden email]"

man tr

--
----------------------------------------------------------------------------
Tim Daneliuk     [hidden email]
PGP Key:         http://www.tundraware.com/PGP/

_______________________________________________
[hidden email] mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "[hidden email]"
Reply | Threaded
Open this post in threaded view
|

Re: case command

Manish Jain-2


On 09/17/17 20:12, 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?

cat <file> | tr '[:upper:]' '[:lower:]'

Regards
Manish Jain

_______________________________________________
[hidden email] mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "[hidden email]"
Reply | Threaded
Open this post in threaded view
|

Re: case command

Manish Jain-2


On 09/17/17 20:26, Steve O'Hara-Smith wrote:

> On Sun, 17 Sep 2017 14:50:00 +0000
> Manish Jain <[hidden email]> wrote:
>
>>
>>
>> On 09/17/17 20:12, 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?
>>
>> cat <file> | tr '[:upper:]' '[:lower:]'
>
> That poor overworked cat :)
>
> tr '[:upper:]' '[:lower:]' < <file>
>

Being the proud owner of a beautiful cat, I rather feel inclined to pay
tribute to the family every now and then  : - )

Regards
Manish Jain
_______________________________________________
[hidden email] mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "[hidden email]"
Reply | Threaded
Open this post in threaded view
|

Re: case command

Matthias Apitz
In reply to this post by Manish Jain-2
On Sunday, 17 September 2017 16:50:00 CEST, Manish Jain
<[hidden email]> wrote:

>
>
> On 09/17/17 20:12, 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?
>
> cat <file> | tr '[:upper:]' '[:lower:]'
>

You won the UU Cat Award.

Re/ the question itself: man dd

matthias



--
Sent from my Ubuntu phone
http://www.unixarea.de/
_______________________________________________
[hidden email] mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "[hidden email]"
Reply | Threaded
Open this post in threaded view
|

Re: case command

FREE BSD QUESTIONS mailing list
In reply to this post by Manish Jain-2
On Sun, 17 Sep 2017 14:50:00 +0000, Manish Jain wrote:
>cat <file> | tr '[:upper:]' '[:lower:]'

$ cd /tmp/
$ echo "ABC" > test-file-1.txt
$ echo "ABC" > test-file-2.txt
$ cat test-file-1.txt | tr '[:upper:]' '[:lower:]' > new-output-file-1.txt
$ tr '[:upper:]' '[:lower:]' < test-file-2.txt > new-output-file-2.txt
$ cat *txt
abc
abc
ABC
ABC

.
_______________________________________________
[hidden email] mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "[hidden email]"
Reply | Threaded
Open this post in threaded view
|

Re: case command

Tim Daneliuk
In reply to this post by Manish Jain-2
On 09/17/2017 10:01 AM, Manish Jain wrote:

>
>
> On 09/17/17 20:26, Steve O'Hara-Smith wrote:
>> On Sun, 17 Sep 2017 14:50:00 +0000
>> Manish Jain <[hidden email]> wrote:
>>
>>>
>>>
>>> On 09/17/17 20:12, 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?
>>>
>>> cat <file> | tr '[:upper:]' '[:lower:]'
>>
>> That poor overworked cat :)
>>
>> tr '[:upper:]' '[:lower:]' < <file>
>>
>
> Being the proud owner of a beautiful cat, I rather feel inclined to pay
> tribute to the family every now and then  : - )
>
> Regards
> Manish Jain

My CEC (Chief Executive Cat) has done a code review and suggests you can
possibly give the kitties a rest break if you quit hitting the pipe:


    tr '[:upper:]' '[:lower:]' <infile | rest of chain


----------------------------------------------------------------------------
Tim Daneliuk     [hidden email]
PGP Key:         http://www.tundraware.com/PGP/

_______________________________________________
[hidden email] mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "[hidden email]"
Reply | Threaded
Open this post in threaded view
|

Re: case command

FREE BSD QUESTIONS mailing list
In reply to this post by FREE BSD QUESTIONS mailing list
On Sun, 17 Sep 2017 17:03:29 +0200, Ralf Mardorf wrote:

>On Sun, 17 Sep 2017 14:50:00 +0000, Manish Jain wrote:
>>cat <file> | tr '[:upper:]' '[:lower:]'  
>
>$ cd /tmp/
>$ echo "ABC" > test-file-1.txt
>$ echo "ABC" > test-file-2.txt
>$ cat test-file-1.txt | tr '[:upper:]' '[:lower:]' >
>new-output-file-1.txt $ tr '[:upper:]' '[:lower:]' < test-file-2.txt >
>new-output-file-2.txt $ cat *txt
>abc
>abc
>ABC
>ABC

And in case "sudo" should be needed, then replace ">" by "| sudo tee".

https://www.freebsd.org/cgi/man.cgi?query=tee&sektion=1&apropos=0&manpath=redhat

.
_______________________________________________
[hidden email] mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "[hidden email]"
Reply | Threaded
Open this post in threaded view
|

Re: case command

FREE BSD QUESTIONS mailing list
In reply to this post by Manish Jain-2
On Sun, 17 Sep 2017 19:40:20 +0200, Polytropon wrote:
>% grep "catfood" < food.txt > mister_kitty.txt

Regarding https://www.freebsd.org/cgi/man.cgi?query=grep&sektion=&n=1
it should work without the "<" the same way it does on Linux [1].

As already pointed out, the inequality signs/angle brackets cause issues
when sudo is required.

[1]
$ ls -hl bar.txt
-r-------- 1 root root 4 Sep 17 19:49 bar.txt
$ sudo grep "foo" < bar.txt > out-file.txt
bash: bar.txt: Permission denied
$ sudo grep "foo" bar.txt > out-file.txt
$ cat out-file.txt
foo
$ sudo grep "foo" bar.txt | sudo tee out-file-2.txt
foo
$ ls -hl out-file*txt
-rw-r--r-- 1 root        root        4 Sep 17 20:00 out-file-2.txt
-rw-r--r-- 1 rocketmouse rocketmouse 4 Sep 17 19:58 out-file.txt

.
_______________________________________________
[hidden email] mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "[hidden email]"
Reply | Threaded
Open this post in threaded view
|

Re: case command

Polytropon
In reply to this post by Tim Daneliuk
On Sun, 17 Sep 2017 16:07:58 -0400, mfv wrote:

> > On Sun, 2017-09-17 at 19:37 Polytropon <[hidden email]> 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.



> 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.

If awk is already part of the pipe chain, it's not a problem
to use it for this task.



> 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/ÂÃÄÅÁ/âãäåá/

For localized 1-byte codes (like german Umlauts), dd can be used.
All methods mentioned so far seem to work correctly:

        % echo "MÄRCHENBÜGELRÖSTER" | dd conv=lcase
        märchenbügelröster
        0+1 records in
        0+1 records out
        19 bytes transferred in 0.000030 secs (632474 bytes/sec)

        % echo "MÄRCHENBÜGELRÖSTER" | tr '[A-Z]' '[a-z]'
        märchenbügelröster

        % echo "MÄRCHENBÜGELRÖSTER" | tr '[:upper:]' '[:lower:]'
        märchenbügelröster

        % echo "MÄRCHENBÜGELRÖSTER" | awk '{ print tolower }'
        märchenbügelröster

This is on a ISO-8859-1 localized system. Even though it is technically
possible, I don't think those "edge cases" will appear in a domain
name list. :-)




--
Polytropon
Magdeburg, Germany
Happy FreeBSD user since 4.0
Andra moi ennepe, Mousa, ...
_______________________________________________
[hidden email] mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "[hidden email]"
Reply | Threaded
Open this post in threaded view
|

Re: case command

Shane Ambler
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 <[hidden email]> 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

_______________________________________________
[hidden email] mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "[hidden email]"
Reply | Threaded
Open this post in threaded view
|

Re: case command

Randal L. Schwartz
In reply to this post by Manish Jain-2
>>>>> "Steve" == Steve O'Hara-Smith <[hidden email]> writes:

Steve> That poor overworked cat :)

I approve this message!

--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<[hidden email]> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix consulting, Technical writing, Comedy, etc. etc.
Still trying to think of something clever for the fourth line of this .sig
_______________________________________________
[hidden email] mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "[hidden email]"
Reply | Threaded
Open this post in threaded view
|

Re: case command

Randal L. Schwartz
In reply to this post by Shane Ambler
>>>>> "Shane" == Shane Ambler <[hidden email]> writes:

Shane> Well as we're listing alternate ways -

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

UUOCA!

perl -ne 'print lc' upper.txt

--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<[hidden email]> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix consulting, Technical writing, Comedy, etc. etc.
Still trying to think of something clever for the fourth line of this .sig
_______________________________________________
[hidden email] mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "[hidden email]"