Find the answer to your Linux question:
Results 1 to 4 of 4
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1

    Simple sed script - SOLVED


    Note, in this post, I am using the word ampersand instead of the symbol in some cases. This is because the forum software auomatically converts ampersand#38; to a single &, if I use the symbol.

    I am trying to write a script which moves through a file, performs a couple of "find and replace" operations and outputs to a new file. The first sed command replaces all instances of %20 with a space. That is working fine. The second sed command is supposed to replace all instances of ampersand#38; with &. That part is not working. Note, when I used sed 's/ampersand#38;/ /g' > new.txt, it did successfully replace all instances of & with a space. I'm sure this is quite simple, I am just missing something.

    The script so far is:

    #! /bin/bash

    sed 's/%20/ /g' testing.txt \
    | sed 's/ampersand#38;/&/g' > new.txt

  2. #2
    Try putting a single backslash ('\') directly in front of each '&' and '#' in your substitute command...

  3. #3
    Thanks. I got mixed up and was using "/", instead of "\".

    All working well now.

    Thanks again.

  4. $spacer_open
  5. #4
    This is what matters the most:
    All working well now.
    "Go henceforth and get mixed up no more..."

Posting Permissions

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