Lower casing all words in a file

Lower casing all words in a file

am 04.12.2007 23:49:06 von laredotornado

Hi,

How do I lower case all the words in a text file? I'm running Fedora
Core 5 Linux and I don't have a preference on shells, although my
default is zsh.

Thanks so much, - Dave

Re: Lower casing all words in a file

am 05.12.2007 00:08:28 von Ed Morton

On 12/4/2007 4:49 PM, laredotornado@zipmail.com wrote:
> Hi,
>
> How do I lower case all the words in a text file? I'm running Fedora
> Core 5 Linux and I don't have a preference on shells, although my
> default is zsh.
>
> Thanks so much, - Dave

tr '[A-Z]' '[a-z]' < file > tmp && mv tmp file

Ed.

Re: Lower casing all words in a file

am 05.12.2007 01:15:30 von Janis Papanagnou

laredotornado@zipmail.com wrote:
> Hi,
>
> How do I lower case all the words in a text file? I'm running Fedora
> Core 5 Linux and I don't have a preference on shells, although my
> default is zsh.

dd if=text.in of=text.out conv=lcase


Janis

>
> Thanks so much, - Dave

Re: Lower casing all words in a file

am 05.12.2007 03:51:04 von krahnj

Ed Morton wrote:
>
> On 12/4/2007 4:49 PM, laredotornado@zipmail.com wrote:
> >
> > How do I lower case all the words in a text file? I'm running Fedora
> > Core 5 Linux and I don't have a preference on shells, although my
> > default is zsh.
> >
> > Thanks so much, - Dave
>
> tr '[A-Z]' '[a-z]' < file > tmp && mv tmp file

Why are you translating '[' to '[' and ']' to ']'?

tr 'A-Z' 'a-z' < file > tmp && mv tmp file



John
--
use Perl;
program
fulfillment

Re: Lower casing all words in a file

am 05.12.2007 04:04:32 von cfajohnson

On 2007-12-05, John W. Krahn wrote:
> Ed Morton wrote:
>>
>> On 12/4/2007 4:49 PM, laredotornado@zipmail.com wrote:
>> >
>> > How do I lower case all the words in a text file? I'm running Fedora
>> > Core 5 Linux and I don't have a preference on shells, although my
>> > default is zsh.
>> >
>> > Thanks so much, - Dave
>>
>> tr '[A-Z]' '[a-z]' < file > tmp && mv tmp file
>
> Why are you translating '[' to '[' and ']' to ']'?

Because there are versions of tr that require a range to be
enclosed in [].

> tr 'A-Z' 'a-z' < file > tmp && mv tmp file


--
Chris F.A. Johnson, author
Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)
===== My code in this post, if any, assumes the POSIX locale
===== and is released under the GNU General Public Licence

Re: Lower casing all words in a file

am 05.12.2007 06:07:49 von wayne

Chris F.A. Johnson wrote:
> On 2007-12-05, John W. Krahn wrote:
>> Why are you translating '[' to '[' and ']' to ']'?
>
> Because there are versions of tr that require a range to be
> enclosed in [].

Such as? Any such system is broken as it violates POSIX.

The only use of '[' and ']' with tr is in a character class,
such as:

$ tr '[:upper:]' '[:lower:]'
-Wayne

Re: Lower casing all words in a file

am 05.12.2007 09:40:40 von cfajohnson

On 2007-12-05, Wayne wrote:
>
>
> Chris F.A. Johnson wrote:
>> On 2007-12-05, John W. Krahn wrote:
>>> Why are you translating '[' to '[' and ']' to ']'?
>>
>> Because there are versions of tr that require a range to be
>> enclosed in [].
>
> Such as?

AT&T SVR3.2

> Any such system is broken as it violates POSIX.

There was no POSIX then.

> The only use of '[' and ']' with tr is in a character class,
> such as:
>
> $ tr '[:upper:]' '[:lower:]' >
> -Wayne


--
Chris F.A. Johnson, author
Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)
===== My code in this post, if any, assumes the POSIX locale
===== and is released under the GNU General Public Licence

Re: Lower casing all words in a file

am 05.12.2007 18:14:22 von Mikhail Teterin

Wayne wrote:

> The only use of '[' and ']' with tr is in a character class,
> such as:
>
> $ tr '[:upper:]' '[:lower:]' 
This is the right method anyway, because the original poster did not
specify, that the file will only consists of US-ASCII characters, so [A-Z]
would fail to capitalize all of the [А-Я], etc.

The character classes, etc. may not be supported by some ancient systems,
but the original poster did specify, that they are using a (fairly) modern
Fedora 5.

-mi

Re: Lower casing all words in a file

am 07.12.2007 12:06:52 von Martien Verbruggen

On Wed, 5 Dec 2007 03:40:40 -0500,
Chris F.A. Johnson wrote:
> On 2007-12-05, Wayne wrote:
>>
>>
>> Chris F.A. Johnson wrote:
>>> On 2007-12-05, John W. Krahn wrote:
>>>> Why are you translating '[' to '[' and ']' to ']'?
>>>
>>> Because there are versions of tr that require a range to be
>>> enclosed in [].
>>
>> Such as?
>
> AT&T SVR3.2

SVR4 shipped in 1989 or 1990 or thereabouts. How many people are still
running SVR3.2? Not just for historical interest, but seriously?

Martien
--
|
Martien Verbruggen | Blessed are the Fundamentalists, for they
| shall inhibit the earth.
|

Re: Lower casing all words in a file

am 07.12.2007 14:18:01 von Ed Morton

On 12/7/2007 5:06 AM, Martien Verbruggen wrote:
> On Wed, 5 Dec 2007 03:40:40 -0500,
> Chris F.A. Johnson wrote:
>
>>On 2007-12-05, Wayne wrote:
>>
>>>
>>>Chris F.A. Johnson wrote:
>>>
>>>>On 2007-12-05, John W. Krahn wrote:
>>>>
>>>>>Why are you translating '[' to '[' and ']' to ']'?
>>>>
>>>> Because there are versions of tr that require a range to be
>>>> enclosed in [].
>>>
>>>Such as?
>>
>> AT&T SVR3.2
>
>
> SVR4 shipped in 1989 or 1990 or thereabouts. How many people are still
> running SVR3.2? Not just for historical interest, but seriously?
>
> Martien

I don't know what version it is, but on the UNIX test harnesses we use in our
labs you still need '[' and ']'. Personally, I've been using that for the past
20 years or so, rarely use it, and have just never found a reason to change - in
fact this is the first time I've even considered checking to see if the "new"
syntax works on all the various UNIX systems I use.

Ed.