I'm trying to replace a substring in $1 with another, AND set it to a variable.
(saved as testStringReplacement file)
#!/bin/bash
secondString="Sara"
myString= "${1/Suzi/$secondString}"
echo "myString = $myString"
Then when I run this:
bash testStringReplacement Suzi
I get this:
testStringReplacement: line 3: Sara: command not found
myString =
Can anyone see what I'm doing wrong? I want myString
to be a string equal to the value of the string substitution (in this case, it should get set to "Sara"). It looks like it's doing the replacement, but trying to then execute it as a command.