sed works from the command line, but does not work if put it in an sh file and execute it. I want to change a number in an existing file and direct it to a new file, so I tried this:
echo enter number
read num
var1='more ods2.sql | egrep -e "test" | cut -c 5-7'
sed "s/test$var1/test$num/g" ods2.sql > odstest.sql
If I execute these statements in a prompt they execute with the desired results. I replaced $var1 with the string I passed, e.g 12345:
sed "s/test$var1/test$num/g" ods2.sql > odstest.sql
This also works fine from a prompt:
more ods2.sql | egrep -e "test" | cut -c 5-7'
Why isn't it working if I put this in a shell script?