HPE Community read-only access December 15, 2018
This is a maintenance upgrade. You will be able to read articles and posts, but not post or reply.
Hours:
Dec 15, 4:00 am to 10:00 am UTC
Dec 14, 10:00 pm CST to Dec 15, 4:00 am CST
Dec 14, 8:00 pm PST to Dec 15, 2:00 am PST
System Administration
cancel
Showing results for 
Search instead for 
Did you mean: 

"\" character cannot been recongized at my UNIX script?????

 
bennyyeung
Occasional Advisor

"\" character cannot been recongized at my UNIX script?????

Hi all,

Why my script cannot recongize "\" this character?????

my input data is window path (eg. c:\testing\abc). When I used my script to echo this data at HPUX 11iv1, it will show "c: esting bc". Please let me know HOW to output as original??????

Thnaks!

Benny
5 REPLIES
Kapil Jha
Honored Contributor

Re: "\" character cannot been recongized at my UNIX script?????

Did you notice one thing in ur outout...
c:\testing\abc
: esting bc

where is \t and \a these are being taken as special characters.

so what u have to is put like.
c:\\testing\\abc
using escape character.
This would work

BR,
Kapil+


I am in this small bowl, I wane see the real world......
Steven Schweda
Honored Contributor

Re: "\" character cannot been recongized at my UNIX script?????

> Why my script [...]

I can't see "my script".

As usual, it might help if you _showed_ the
actual commands you used, instead of only
describing them.

man sh
man

"\" is a special character to a typical UNIX
shell, so it must be handled in a special
way.

dy # echo c:\testing\abc
c:testingabc

dy # echo 'c:\testing\abc'
c:\testing\abc

dy # echo "c:\testing\abc"
c:\testing\abc

dy # echo c:\\testing\\abc
c:\testing\abc

dy # uname -a
HP-UX dy B.11.11 U 9000/785 2012616114 unlimited-user license
Steven Schweda
Honored Contributor

Re: "\" character cannot been recongized at my UNIX script?????

> [...]
> dy # echo 'c:\testing\abc'
> c:\testing\abc
> [...]

That was using bash, by the way. I also
don't know which shell you were using.
Kapil Jha
Honored Contributor

Re: "\" character cannot been recongized at my UNIX script?????

missprint... :)
it should be
c:/\testing/\abc


BR,
Kapil+
I am in this small bowl, I wane see the real world......

Re: "\" character cannot been recongized at my UNIX script?????

If it isn't obvious to you, in general Unix shells really really hate backslashes. They are using for escaping or quoting other chars, including itself.

Steven has showed you what happens for the 4 cases of no quoting, using "", '' or \\.

Where does your data come from?
A file, a variable, from the command line?

Once you get it into a variable, you don't have to quote it again.