Operating System - HP-UX
1753774 Members
6812 Online
108799 Solutions
New Discussion юеВ

Re: "\" 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 5
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......
Dennis Handly
Acclaimed Contributor

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.