Simpler Navigation coming for Servers and Operating Systems
Coming soon: a much simpler Servers and Operating Systems section of the Community. We will combine many of the older boards, and you won't have to click through so many levels to get at the information you need. If you are looking for an older board and do not find it, check the consolidated boards, as the posts are still there.
Languages and Scripting
cancel
Showing results for 
Search instead for 
Did you mean: 

ksh replace single qoutes in var.

SOLVED
Go to solution
Trento
Occasional Visitor

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

5 REPLIES
Shibin_2
Honored Contributor
Solution

Re: ksh replace single qoutes in var.

How about print ? Replace echo with print and try.
Regards
Shibin
Dennis Handly
Acclaimed Contributor

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 "'")
Highlighted
Mike Miller_8
Regular Advisor

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 ?
James R. Ferguson
Acclaimed Contributor

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...
Steven Schweda
Honored Contributor

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?