Find the answer to your Linux question:
Results 1 to 3 of 3
how i can use prep when the strings i want to search and replace have the '/' character in them? ie - i need to change every instance of /home/sites/ccweb/web/admin ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Apr 2005
    Location
    Denmark
    Posts
    3

    prep question


    how i can use prep when the strings i want to search and replace have the '/' character in them? ie - i need to change every instance of /home/sites/ccweb/web/admin to /home/sites/ccweb/web-content - the problem being, of course, that the string for prep is s/original/changeto/g - which uses the '/' character itself. i tried escaping each / that i used by \/ - so s/home\/sites\/ccweb\/web\/admin/home\/sites\/ccweb\/web-content - but this just pissed prep off... any advice?

  2. #2
    Linux Enthusiast
    Join Date
    Jan 2005
    Posts
    575
    I've never heard of prep before but you can use sed:
    Code:
     sed s+/home/sites/ccweb/web/admin+/home/sites/ccweb/web-content+g
    You can use most characters as delimiters in place of +

  3. #3
    Just Joined!
    Join Date
    Apr 2005
    Location
    Denmark
    Posts
    3
    ah thanks!

    the s+first+second+g syntax worked just fine in prep.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •