|
|||||||
| Forums | Search Forums | Register | Forum Rules | Man Pages | Albums | FAQ | Members | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
|
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Different behavour with "tr"
I am getting different output with the 'tr' command in bash I am using Linux: Red Hat Enterprise Linux Server release 5.3 (Tikanga) Bash version: GNU bash, version 3.2.25(1)-release (x86_64-redhat-linux-gnu) Code:
$ x=`echo XXx | tr '[a-z]' '[A-Z]' ` $ echo $x XXX $ y=`echo XXx | tr [:lower:] [:upper:] ` $ echo $y XXx |
| Sponsored Links | ||
|
|
#2
|
|||
|
|||
|
Probably a character-set thing. The GNU utilities try to abide by your character set whenever possible, and UTF8 is increasingly standard, but the definition of :lower: and :upper: for UTF8 is going to be pretty big and complicated.
Other side-effects of this compliance are things like slow-performing grep -i. Try LOCALE="C" tr ... and see if it works as expected. Also, if you have a file in your directory named :, l, o, w, e, r, u, or p, [:lower:] and [:upper:] will actually glob those filenames, so put them in single quotes! '[:lower:]' '[:upper:]' |
| The Following User Says Thank You to Corona688 For This Useful Post: | ||
jville (12-05-2012) | ||
| Sponsored Links | ||
|
|
#3
|
|||
|
|||
|
Quote:
The issue with locales which interleave upper and lower case letters (such as english utf-8) typically manifests as unintended conversions. I would suggest, as you did, to quote the arguments to tr. For confirmation, set -x . Regards, Alister |
| The Following User Says Thank You to alister For This Useful Post: | ||
jville (12-05-2012) | ||
|
#4
|
|||
|
|||
|
that explains it.
globbing was the culprit in this case. I had a file with 'w' in directory where I was executing this command. Thanks for your help ! |
| Sponsored Links | ||
|
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| The slices "usr", "opt", "tmp" disappeared!!! Help please. | wolfgang | Solaris | 16 | 05-25-2012 08:09 AM |
| how to use "cut" or "awk" or "sed" to remove a string | timmywong | Shell Programming and Scripting | 8 | 02-12-2012 11:55 AM |
| awk command to replace ";" with "|" and ""|" at diferent places in line of file | shis100 | Shell Programming and Scripting | 7 | 03-16-2011 08:59 AM |
| Explain the line "mn_code=`env|grep "..mn"|awk -F"=" '{print $2}'`" | Lokesha | UNIX for Dummies Questions & Answers | 4 | 12-20-2007 12:52 AM |
|
|