- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Echo and backslash
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
Discussions
Discussions
Forums
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
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
тАО09-12-2008 05:22 AM
тАО09-12-2008 05:22 AM
I'd like to produce the echo below:
123\\abc
I've tried echo "123\\abc" or "123\\\\abc"without succes !
Any Idea ?
Regards
Den
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-12-2008 05:26 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-12-2008 05:35 AM
тАО09-12-2008 05:35 AM
Re: Echo and backslash
123\\abc
dy # echo "123\\\\abc"
123\\abc
dy # uname -a
HP-UX dy B.11.11 U 9000/785 2012616114 unlimited-user license
Of course, that's using bash. With /bin/sh,
it seems to be harder.
dy # echo "123"'\\\\'"abc"
123\\abc
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-12-2008 06:11 AM
тАО09-12-2008 06:11 AM
Re: Echo and backslash
echo "123\\\\\\acb"
works as well.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-12-2008 06:18 AM
тАО09-12-2008 06:18 AM
Re: Echo and backslash
> Steven: Of course, that's using bash. With /bin/sh, it seems to be harder.
...and without rancor, I would have to say that since this is HP-UX it's fair to assume that we should be using the *standard* HP-UX shell ('/usr/bin/sh' or '/sbin/sh'). The bash shell's handling of backslashes in its implementation of 'echo' differs significantly.
On an 11.11 machine:
# echo ${SHELL}
/sbin/sh
# echo "123\\abc"
123bc
# echo "123\\\\abc"
123\abc
# echo "123\\\\\\\\abc"
123\\abc
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-12-2008 07:01 AM
тАО09-12-2008 07:01 AM
Re: Echo and backslash
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-12-2008 07:26 AM
тАО09-12-2008 07:26 AM
Re: Echo and backslash
> that since this is HP-UX it's fair to
> assume that we should be using the
> *standard* HP-UX shell ('/usr/bin/sh' or
> '/sbin/sh').
Assume what you wish, but "should" is your
opinion. Bash runs on HP-UX, too, however.
> The bash shell's handling of
> backslashes in its implementation of 'echo'
> differs significantly.
No argument there.
> # echo ${SHELL}
> /sbin/sh
Not a good test.
dy # echo "123\\\\abc"
123\\abc
dy # echo $SHELL
/sbin/sh
SHELL is not guaranteed to agree with the
current shell.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-12-2008 06:49 PM
тАО09-12-2008 06:49 PM
Re: Echo and backslash
One thing about quoted strings, you'll need to double up backslashes in "" vs ''.
So one would think that this would work:
echo "123\\\\abc"
echo '123\\abc'
Unfortunately this doesn't work because echo then has its own rules about backslashes.