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

    sed variable containing space error

    Hello , i am trying to replace some code from all files in folder with something else but not manage to do it. i think that if source contains spaces there is my problem

    #!/bin/sed -f
    w="What to change"
    grep -lR $w ./ | while read caca; do sed -i "s/$w/THE NEW VALUE/g" %caca done

  2. #2

    what's that mess?

    this kind of script can't have such a shebang!

    %caca is not a valid variable, and you know it as you already used $w!

    it's more probably the grep statement which errors, double quote $w:
    grep -lR "$w" | while...
    you're missing a semicolon before `done` too.

Posting Permissions

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