- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Make echo ignore the "\" char
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-15-2003 11:09 AM
04-15-2003 11:09 AM
Does anyone know how to make echo ignore the special meaning of the "\" character.
I.E. I would like to be able to store the line "c:\temp" in a variable (var) and then use the command "echo $var" to get "c:\temp" to print. HOWEVER, what is happening now is I store "c:\temp" in var and the "echo $var" responds with ...
"c: emp"
... or "c COLON TAB emp" because it interprets the "\t" part of "\temp" as the escape code for "tab".
Thanks!
Mike
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-15-2003 11:13 AM
04-15-2003 11:13 AM
Re: Make echo ignore the "\" char
# export TEST="c:\\\test"
# echo $TEST
c:\test
Rgds...Geoff
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-15-2003 11:16 AM
04-15-2003 11:16 AM
Re: Make echo ignore the "\" char
export kenvar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-15-2003 11:25 AM
04-15-2003 11:25 AM
Re: Make echo ignore the "\" char
Basically, I need to be able to read "C:\temp" into a variable from a file, and echo it (or print it using any other method) exactly as read to another file.
Thanks forthe help!
Mike
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-15-2003 11:27 AM
04-15-2003 11:27 AM
Re: Make echo ignore the "\" char
I don't know if this vcan be something for you:
a='C:\ddd'
# echo $a
C:\ddd
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-15-2003 11:28 AM
04-15-2003 11:28 AM
Re: Make echo ignore the "\" char
echo $var
Thanks
Zafar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-15-2003 11:40 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-15-2003 11:42 AM
04-15-2003 11:42 AM
Re: Make echo ignore the "\" char
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-15-2003 11:44 AM
04-15-2003 11:44 AM
Re: Make echo ignore the "\" char
I think the problem is not the echo command, it is the read.
try
# cat zzz
C:\ddd
# while read -r a
> do
> echo $a
> done
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-15-2003 11:59 AM
04-15-2003 11:59 AM
Re: Make echo ignore the "\" char
This one is awful, but it works:
awk 'END { print ENVIRON["var"] }'
Replace echo with the above line... Another solution would be to write a small C program which prints all of its nonzero arguments... I didn't find a better solution to this simple problem!
Hehe, by the way, this is a major ITRC issue, look at this one:
1) Click on the name of one of the contributors of this thread (author excluded), to view its profile
2) Have a look at the thread subject, in the "Responses" column
3) Where the heck is the backslash?
Mike, I wonder if you're working on the ITRC web interface!
Regards,
Olivier
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-15-2003 12:04 PM
04-15-2003 12:04 PM
Re: Make echo ignore the "\" char
I was using the "cat filename | while read var" to get the lines from the file. Unfortunately, SOME ofthe lines had double "\" (I.E. C:\\Temp", and "print -r" by itself was still outputting "C:\temp" for these as well.
However changing the script to (paraphrased)...
#!/bin/ksh
cat filename | while read -r line
do
print -r $line >> newfile
done
...managed to allow the line top be read and written without corruption.
Thanks a million!
Mike
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-15-2003 12:04 PM
04-15-2003 12:04 PM
Re: Make echo ignore the "\" char
I was using the "cat filename | while read var" to get the lines from the file. Unfortunately, SOME ofthe lines had double "\" (I.E. C:\\Temp", and "print -r" by itself was still outputting "C:\temp" for these as well.
However changing the script to (paraphrased)...
#!/bin/ksh
cat filename | while read -r line
do
print -r $line >> newfile
done
...managed to allow the line to be read and written without corruption.
Thanks a million!
Mike