Operating System - HP-UX
1753930 Members
9858 Online
108810 Solutions
New Discussion юеВ

tr output different in other directories

 
SOLVED
Go to solution
Paul Gold
Advisor

tr output different in other directories

using the tr command in the following way

in user home directory /na/tmc/jcl

#echo "STAND1" | tr [A-Z] [a-z]

gives the expected result

#stand1

if I then cd to /na/tmc/jcl/tmc and run the same command I get a usage error

#tr:the combination of options and string parameters is not legal

this happens for users and superuser

there is no tr file in current directory
results the same for ksh and sh shell

also if i do the same tr command in the root directory i get the following results

#STaND1

anyone got any ideas?

Paul Gold
CAST
7 REPLIES 7
Carlos Fernandez Riera
Honored Contributor

Re: tr output different in other directories



Easy:

echo "STAND1" | tr "[A-Z]" "[a-z]"
unsupported
Alex Glennie
Honored Contributor

Re: tr output different in other directories

Paul .... do we know one another by any chance, your name sounds familiar ;~)
& did the previous post resolve your problem ?
Andreas Voss
Honored Contributor

Re: tr output different in other directories

Hi,

this could be a shell expansion problem because you have not quoted the tr arguments.
In one directory there seem to be no file which begins with A-Z or a-z.
In the other directory there are possibly files which begin with these chars an so the shells expands the [A-Z] or [a-z] and you get a syntax error for tr.

Greetings

Andrew
Paul Gold
Advisor

Re: tr output different in other directories

hello all, thanks fo rthe help

unfortunately it doesnt work

if we do

#echo "STAND1" | tr "[A-Z]" "[a-z]"

we get

ksh "[A-Z]" not found

the developer has found a workaround but would like to know why the original problem happened (dont they always) :-)

#echo STAND1 | tr [A-Z] a-z

it works in ALL directories

any explanations please ?

Paul Gold
CAST

PS hi Alex, never heard of you :-), yes its me, these forums are a lot easier than logging calls with OSD Boeblingen, when the forums are working that is
Andreas Voss
Honored Contributor

Re: tr output different in other directories

Hi Paul,

it seems to me very strange that you get
ksh "[A-Z]" not found

But your initial problem by my though was the shell expansion:
Try this:
Make a new directory
Change to that directory
Touch two files: touch A B
Try your command and i bet that you get the error: tr:the combination of options and string parameters is not legal

Let me explain:
If the string [A-Z] is not qouted, the shell expands in this case [A-Z] to AB because you have a file named A and a file named B.
So the results of the tr command is:
tr A B a-z
and that didn't work.
You can easisly check the result of [A-Z]
by using:
echo [A-Z]

Hope i was right.

Greetings

Andrew
Andreas Voss
Honored Contributor
Solution

Re: tr output different in other directories

Just another issue:

To map uppercase to lowercase you can also use:

tr '[:upper:]' '[:lower:]'

Andrew
Paul Gold
Advisor

Re: tr output different in other directories

Andrew

thanks for the help

I think the developer (and others)have some screwy things in their profiles as I got it working by removing the generic one and then using your quoted commands

Paul Gold
CAST