GNU sed version 4.1.2 swap text containing /

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • motorbikes
    New Member
    • Dec 2007
    • 1

    GNU sed version 4.1.2 swap text containing /

    I want to go through a file and swap anything that says http://nameofsite.com to ftp://nameofsite.com

    sed s/http://nameofsite.com/ftp://nameofsite.com/ test.file

    won't work because the text contains /

    any help please?
  • arne
    Recognized Expert Contributor
    • Oct 2006
    • 315

    #2
    Originally posted by motorbikes
    I want to go through a file and swap anything that says http://nameofsite.com to ftp://nameofsite.com

    sed s/http://nameofsite.com/ftp://nameofsite.com/ test.file

    won't work because the text contains /

    any help please?
    What about

    sed s/http/ftp/ test.file ?

    If you other have other http entries you don't want to change, try \ (backslash) to escape / (forward slash):

    sed s/http:\/\/nameofsite.com/ftp:\/\/nameofsite.com/ test.file

    I'm not an expert in sed though ...

    HTH,
    arne

    Comment

    Working...