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

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

command TR suddenly fails

Reply to Message Icon

Name: tvc02
Date: June 3, 2008 at 07:02:58 Pacific
OS: w2k
CPU/Ram: n/a
Product: 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 ?



Sponsored Link
Ads by Google

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

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

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


0

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

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.


0

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

Does it help to place quotes around the tr arguments:

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


0

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

That works perfectly, Thanks

Can you explain why it sometimes works without the quotes ?


0

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

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.


0

Related Posts

See More



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

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


0

Response Number 7
Name: isavant01
Date: December 5, 2008 at 08:46:57 Pacific
Reply:

globbing.

you'll probably find that there is/was a file in the current directory that MATCHED the [a-z] or [A-Z] on your tr command line.

the shell interpreted the UNquoted [a-z] or [A-Z] AS the file so named ... which completely blew up what you were trying to do.

"That's the problem with these things [computers], they do what you tell them, not what you meant to tell them."
--- Danielle Needle


0

Sponsored Link
Ads by Google
Reply to Message Icon






Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Unix Forum Home


Sponsored links

Ads by Google


Results for: command TR suddenly fails

SQL in shell script www.computing.net/answers/unix/sql-in-shell-script/5703.html

Unix Cron Job www.computing.net/answers/unix/unix-cron-job/7457.html

find file www.computing.net/answers/unix/find-file-/2811.html