I have an variable
qsubFile="submitJob.sh"
echo $qsubFile returns submitJob.sh without the double quotes.
Now, I want to find the line containing the string qsubFile="someOtherFile.sh" and replace it to qsubFile="submitJob.sh" in the file "write.sh".
I tried using
sed -i '/qsubFile=/c\qsubFile="'"$qsubFile"'"' write.sh
qsubFile=""
I can’t seem to get the proper syntax for this.
but it replaces it as
You just need single quotes for
sedto do this, there is no problem with the double quotes inside the single quotes:If
"someOtherFile.sh"isn’t a fixed string inwrite.shthan use the follow to replace them all:Regex
"[^"]*":Seems I misread the question the first time the correct quoting is to use the variable
$qsubFileis, you missed the last/: