- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- echo question
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
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
тАО07-16-2003 07:47 AM
тАО07-16-2003 07:47 AM
I am using echo "\a\nancy\file" but the echo output I get is following..
echo "\a\nancy\file"
ancy
ile
Because \ is a speacial charactor for new line, any idea how to solve this, I want the output of echo would be same as \a\nancy\file.
Thanks in advance
Anthony
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-16-2003 07:49 AM
тАО07-16-2003 07:49 AM
Re: echo question
man printf
Share and Enjoy! Ian
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-16-2003 07:54 AM
тАО07-16-2003 07:54 AM
Re: echo question
# echo '\\a\\nancy\\file'
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-16-2003 07:58 AM
тАО07-16-2003 07:58 AM
Re: echo question
echo '\\a\\nancy\\file'
works for me. you need to excape the \a the \n and the \f
the escape character is \
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-16-2003 08:02 AM
тАО07-16-2003 08:02 AM
Re: echo question
You'll need to escape the backslashes with a backslash, ie:
echo "\\a\\nancy\\file"
You may want to use something like sed to automate this if you've got a lot of these to change ;)
regards,
Darren.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-16-2003 08:13 AM
тАО07-16-2003 08:13 AM
Re: echo question
you really should be using the "print" command as echo is obsolete. echo and print formats several escape conventions including:
\a bell character
\n newline
\f formfeed
and
\\ backslash
with the echo command your stuck with using \\ for a backslash. with the print command you can also use the -R and -r switches which do not use the \ conventions.
and if your shell has a printf command you can also use or not use the \ conventions depending on your conversion specification (%s or %b).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-16-2003 08:24 AM
тАО07-16-2003 08:24 AM
Re: echo question
Curt's suggestion to use the 'print -R' syntax is the most direct answer to your problem. This is documented in the man pages for 'sh-posix'.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-16-2003 08:57 AM
тАО07-16-2003 08:57 AM
Re: echo question
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-16-2003 09:06 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-16-2003 09:11 AM
тАО07-16-2003 09:11 AM
Re: echo question
cat mjk-test | sed -e 's/\\a/\\\\a/' -e 's/\\n/\\\\n/'
HTH,
Michael.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-16-2003 09:26 AM
тАО07-16-2003 09:26 AM
Re: echo question
echo $(print -r $a | sed 's|\\|\\\\|g')
# this will work just as well (actually better)
print -r $a
#if you're using the korn shell you can also do
printf "%s" $a