LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
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!

Notices


Reply
  Search this Thread
Old 01-31-2014, 04:19 PM   #1
aaadougford
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.

/home/dford/DataOneNew/lifestyle_gallery/hash/f/e/f~6d2d5682ec7f3ab835d1eb089876f8dd29ea0fef.jpg

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

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

Eg.
Code:
sed 's/~/\//'
 
Old 01-31-2014, 05:01 PM   #3
MARogue
Member
 
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.

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

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

Markus
 
  


Reply


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 11:40 AM
sed search and replace question the_rhino Linux - General 3 12-10-2012 03:25 AM
Multi-line find/replace with GnuWin32 Sed Question EdrickV Programming 4 04-26-2009 01:32 PM
sed question for search and replace jakev383 Linux - General 8 05-05-2007 05:40 AM
sed or awk question - replace caps with small letters computera Linux - General 1 12-30-2003 04:39 AM


All times are GMT -5. The time now is 03:46 PM.

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