1832143 Members
3066 Online
110038 Solutions
New Discussion

change to lowercase

 
SOLVED
Go to solution
Fred Martin_1
Valued Contributor

change to lowercase

I have a file containing two fields only:

i81LhMG00169:

I need to convert everything in the second field to lowercase, but need to retain the case in the first field.

Seems like there should be a one-liner in awk or sed that can do this. No perl please.
fmartin@applicatorssales.com
2 REPLIES 2
Hein van den Heuvel
Honored Contributor
Solution

Re: change to lowercase

What constitues a fields in your file?
Are fields seperated by spaces or that colon?
Will there only ever be 2 fields?

For 2 'simple' fields the awk solution is:

awk '{print $1,tolower($2)}' your-file


For any more complex definition of fiels I would recommend a perl solution :-).

Just curious, as I am alway eager to learn, why not perl? It's regular expressions are very helpfull breaking down lines into fields and such.

Cheers,
Hein.
Fred Martin_1
Valued Contributor

Re: change to lowercase

Yeah it's just the two fields, a space between, although every mailID does end in a colon. Your awk solution works perfect - I'd forgotten about tolower().

Nothing against perl, I just don't know it. I have the O'Reilly Learning Perl book but haven't gotten to it yet.

Just need (as ever) a quick solution for today.
fmartin@applicatorssales.com