Re: ksh replace single qoutes in var. (248 Views)
Reply
Occasional Visitor
Trento
Posts: 1
Registered: ‎12-06-2010
Message 1 of 6 (248 Views)
Accepted Solution

ksh replace single qoutes in var.

Hi,

I kind of stuck on easy thing how to apply command I can use from prompt inside my ksh script.
I need to replace single qoute in my var,
this work ok from prompt:
$ echo $mm|tr -d "'"
.
but how put this into new var or change existing $mm value inside the script? I know how to do it with file, but d'like to stay with var.
e.g.
$ mmm=`echo $mm|tr -d "'"` # this gaves me an error.

Appreciate you help on this easy for you subject. I check my manuals it's all clear untill hands on sample.

Best
Tr

Honored Contributor
Shibin_2
Posts: 711
Registered: ‎11-11-2005
Message 2 of 6 (248 Views)

Re: ksh replace single qoutes in var.

How about print ? Replace echo with print and try.
Regards
Shibin
Acclaimed Contributor
Dennis Handly
Posts: 25,281
Registered: ‎03-06-2006
Message 3 of 6 (248 Views)

Re: ksh replace single qoutes in var.

>this gives me an error.

What does $mm have in it? What error do you have?
I have no problems with:
mm2=$(echo $mm | tr -d "'")
Regular Advisor
Mike Miller_8
Posts: 89
Registered: ‎02-24-2003
Message 4 of 6 (248 Views)

Re: ksh replace single qoutes in var.

echo $mm
"This is a test"
nn=$(echo $mm | tr -d '"')
echo $nn
This is a test


Is this what you are looking for ?
Acclaimed Contributor
James R. Ferguson
Posts: 21,184
Registered: ‎07-06-2000
Message 5 of 6 (248 Views)

Re: ksh replace single qoutes in var.

Hi:

So, it appears that the suggestions offered solved your problem, based on point assignment. In that case, *exactly* what eliminated the error that you were encountering, and what *exactly* was that error?

Regards!

...JRF...
Honored Contributor
Steven Schweda
Posts: 9,096
Registered: ‎02-23-2005
Message 6 of 6 (248 Views)

Re: ksh replace single qoutes in var.

> [...] and what *exactly* was that error?

You weren't still hoping for a clear
statement of the problem, were you? This
_is_ the HP-UX forum, isn't it?
The opinions expressed above are the personal opinions of the authors, not of HP. By using this site, you accept the Terms of Use and Rules of Participation.