1832241 Members
2832 Online
110041 Solutions
New Discussion

tr bug or feature?

 
SOLVED
Go to solution

tr bug or feature?

Hello,
I need to convert text to lower case, and i was using tr like, tr -s [:upper:] [:lower:] < Orig_file > new_file.
It converts all upper case to lower but if some letter is repeating, then tr leave only one.
Thanks for response.
Franta.
4 REPLIES 4
Fred Ruffet
Honored Contributor
Solution

Re: tr bug or feature?

It's a feature, as long as you use -s. just use
tr "[:upper:]" "[:lower:]" < in > out

man tr

Regards,

Fred
--

"Reality is just a point of view." (P. K. D.)
Mark Grant
Honored Contributor

Re: tr bug or feature?

Umm, that is exactly what the "-s" option is supposed to do!!!

I quite from the man page

"Replaces any character specified in string1 that occurs as a string of two or more repeating characters as a single instance of the character in string2"
Never preceed any demonstration with anything more predictive than "watch this"
Mark Grant
Honored Contributor

Re: tr bug or feature?

Or, you could try this,

perl -i -pne 'tr/a-z/A-Z/'

Careful though as this edits the file in place.
Never preceed any demonstration with anything more predictive than "watch this"

Re: tr bug or feature?

Thanks, possibly I need eye-glasses :-)).
It works fine.
Franta.