Computing.Net > Forums > Unix > command TR suddenly fails

command TR suddenly fails

Reply to Message Icon

Original Message
Name: tvc02
Date: June 3, 2008 at 07:02:58 Pacific
Subject: command TR suddenly fails
OS: w2k
CPU/Ram: n/a
Model/Manufacturer: n/a
Comment:

Using TR command like this:

echo Test | tr [A-Z] [a-z]

... with Bourne shell. Worked OK for a bunch of users on same server, suddenly, it does not work anymore for 1 particular user.

I do not see any differences between this user and other ones. When it fails, he just displays : "Test"

For the other users, he displays "test"

What's wrong ?


Report Offensive Message For Removal


Response Number 1
Name: med (by medigeek)
Date: June 3, 2008 at 07:57:37 Pacific
Reply: (edit)

try:
echo Test | tr [:upper:] [:lower:]

maybe it's a different shell? what does "echo $0" say?


Report Offensive Follow Up For Removal

Response Number 2
Name: tvc02
Date: June 4, 2008 at 03:47:06 Pacific
Reply: (edit)

The shell is not different, both have /usr/bin/bash as shell, checked that as first thing.

If I use syntax:

echo Test | tr [:upper:] [:lower:]

... I'm getting "Bad String", on the user that does work, if you do :

echo Test | tr [upper] [lower]


I'm gessing that the TR command is just buggy, but I would like somebody to confirm this. There's obviously an external factor, deciding on the behaviour of this command, which should not be.


Report Offensive Follow Up For Removal

Response Number 3
Name: nails
Date: June 4, 2008 at 10:32:58 Pacific
Reply: (edit)

Does it help to place quotes around the tr arguments:

echo Test | tr "[A-Z]" "[a-z]"


Report Offensive Follow Up For Removal

Response Number 4
Name: tvc02
Date: June 9, 2008 at 01:56:40 Pacific
Reply: (edit)

That works perfectly, Thanks

Can you explain why it sometimes works without the quotes ?


Report Offensive Follow Up For Removal

Response Number 5
Name: nails
Date: June 9, 2008 at 20:07:29 Pacific
Reply: (edit)

I'm running these tr tests on a Solaris 9 unix box. Both examples work fine, but the Solaris tr MAN pages examples exclusively use quotes around the tr arguments.

Until I saw your post, I had never heard of not using quotes. I looked in my favorite Unix reference - Unix in a Nutshell - and this reference exclusively uses quotes.

If I were you, I'd exclusively use quotes as obviously without quotes tr usage is inconsistent.


Report Offensive Follow Up For Removal


Response Number 6
Name: tvc02
Date: June 10, 2008 at 02:06:32 Pacific
Reply: (edit)

OK Thanks,
I'm using Solaris 10 by the way

I need to updat all my scripts now, because otherwise it does not run for this one unix-user only, since some days, for an unknown reason


Report Offensive Follow Up For Removal






Use following form to reply to current message:

   Name: From My Computing.Net Settings
 E-Mail: From My Computing.Net Settings

Subject: command TR suddenly fails

Comments:

 


  Homepage URL (*): 
Homepage Title (*): 
         Image URL: 
 
Data Recovery Software




Have you ever used OpenOffice?

Yes, as my main suite.
Yes, occationally.
Yes, but only once.
No, never.


View Results

Poll Finishes In 5 Days.
Discuss in The Lounge