Hello Master Scripters,
I am in scripting nursery and I am trying to write a script that will replace string a with string b. I can get my script to replace single strings with no problem, my issue arrives when one of my strings has two words. I am pretty sure that there are quotes involved for this. Now, can the quotes be in the script instead of being written in the command line. If I run my script with the quotes in the command line the script works perfectly.
My script currently looks like this:
#!/bin/csh
set stringa=$1
set stringb=$2
set filename=$3
sed s/$stringa/$stringb/g $filename
I have tried to run it with
set "stringa"=$1
, but this gives me a syntax error.
I have tried to run it with
set stringa="$1"
, and this seems to have the same effect as no quotes.
I tried also to run it with everything above the sed line without quotes and then the
sed s/"$stringa/"$stringb"/g $filename
, with no luck.
Any other suggestion on how to accomplish this task?