Results 1 to 2 of 2
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 ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
- 11-22-2012 #1Just Joined!
- Join Date
- Nov 2012
- Posts
- 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
- 11-22-2012 #2Linux Newbie
- Join Date
- Nov 2012
- Posts
- 134
hi,
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:you're missing a semicolon before `done` too.Code:grep -lR "$w" | while...


Reply With Quote
