Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 01-31-2014, 05:19 PM   #1
LQ Newbie
Registered: Jan 2014
Posts: 1

Rep: Reputation: Disabled
sed replace question

In the path you see below with sed I'm trying to replace the ~ with a /.

It doesn't work with sed 's/~///'

I'm sure there is a something to tell sed to take the / as the replacement character.


Please help
Old 01-31-2014, 05:58 PM   #2
Registered: Jul 2004
Location: USA
Distribution: Slackware64
Posts: 211

Rep: Reputation: 50
You need to "escape" the slash.

sed 's/~/\//'
Old 01-31-2014, 06:01 PM   #3
Registered: Jul 2011
Location: USA
Distribution: Ubuntu 12.04 , Debian "Wheezy"
Posts: 56

Rep: Reputation: Disabled
This page on sedhas helped me a great deal. Maybe you will find it useful.

Old 01-31-2014, 06:21 PM   #4
Senior Member
Registered: Apr 2007
Location: Germany
Distribution: Slackware
Posts: 3,979

Rep: Reputation: Disabled
Originally Posted by aaadougford View Post
It doesn't work with sed 's/~///'
But this
sed 's&~&/&'
will work because you can replace the '/' with any other character as long as it is not used within the pattern.



Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Question regarding awk or sed to find and replace a word in Solaris for Scripting karthik1asr Linux - Newbie 3 03-29-2013 12:40 PM
sed search and replace question the_rhino Linux - General 3 12-10-2012 04:25 AM
Multi-line find/replace with GnuWin32 Sed Question EdrickV Programming 4 04-26-2009 02:32 PM
sed question for search and replace jakev383 Linux - General 8 05-05-2007 06:40 AM
sed or awk question - replace caps with small letters computera Linux - General 1 12-30-2003 05:39 AM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 02:26 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration