Find the answer to your Linux question:
Results 1 to 3 of 3
I want to replace the following string: mnt\I\F with: mnt\F\F I know to use something like: sed -i 's/I/F/g' filename but don't understand how to process the \ characters, using: ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Aug 2011
    Posts
    2

    replacing string in a file


    I want to replace the following string:
    mnt\I\F
    with:
    mnt\F\F

    I know to use something like:
    sed -i 's/I/F/g' filename

    but don't understand how to process the \ characters, using:
    sed -i 's/mnt\I\F/mnt\F\F/g' filename
    isn't working.

    I want to do something like:

    find . -type f -exec sed -i 's/mnt\I\F/mnt\F\F/g' {} \;

  2. #2
    Just Joined! cfajohnson's Avatar
    Join Date
    May 2007
    Location
    Toronto, Canada
    Posts
    52

    Escape the backslashes:
    Code:
    find . -type f -exec sed -i 's/mnt\\I\\F/mnt\\F\\F/g' {} +

  3. #3
    Just Joined!
    Join Date
    Aug 2011
    Posts
    2
    Thanks for your help. Thought for sure I tried that, but guess I didn't since it worked

Posting Permissions

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