- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Backslash in SED
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
тАО01-08-2001 12:40 PM
тАО01-08-2001 12:40 PM
Command 1 = export $SESSION = echo 2000/12/31-5 | sed -e "s/\//\/g" # (Replace / with \/ - doesn't work)
Command 2 = sed -e "s/var1/$SESSION/g" # ($SESSION = result of Command1)
Any ideas?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-08-2001 12:53 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-08-2001 12:56 PM
тАО01-08-2001 12:56 PM
Re: Backslash in SED
and, of course, if you use a different delimiter you don't need to backslash your slashes in the substitution
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-08-2001 12:57 PM
тАО01-08-2001 12:57 PM
Re: Backslash in SED
Try:
# echo 2000/12/31-5 | sed -e "s?/?\\\?g"
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-08-2001 03:53 PM
тАО01-08-2001 03:53 PM
Re: Backslash in SED
Interesting point; the answers above gives the result I wanted to stdout, but to store it in a variable, I had to put another 3 \ characters in the sed command. End result was
export S2='echo $S1|sed -e "s?/?\\\\\\\/?g"'
with ? as delimeter.
FRED
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-09-2001 02:41 AM
тАО01-09-2001 02:41 AM
Re: Backslash in SED
The reason why you have to add a couple backslashes when assigning the result to a variable is the following:
Using double quotes doesn't prevent your shell from interpreting the string, you should use simple quotes instead, like in:
a=`echo 2000/12/31-5 | sed -e 's#/#\\\#g'`
This keeps the whole expression 'more readable'. ;-)
Best regards,
Dan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-09-2001 07:55 AM
тАО01-09-2001 07:55 AM
Re: Backslash in SED
Regards
ian