I am writing a shell script to replace a variable content which is an integer with another, using perl in a shell script.
#!/bin/sh
InitialFileStep="$1"
CurrentStage=$((($i*(9*4000))+$InitialFileStep))
PreviousStage=$((($(($(($i-1))*(9*4000)))) + (InitialFileStep)))
perl -pi -e 's/$PreviousStage/$CurrentStage/g' file.txt
echo "Hey!"
It seems it cannot find the variable content in the file. I don't know what is the problem, is it the because the variables are integers and not strings?
test.sh: line 4: (*(9*4000))+42: syntax error: operand expected (error token is "*(9*4000))+foo"). Where does$icome from?