sed not working in a bash script

Hi friends,

I have two files - input and commands

I want to read the input and replace a value in it with the contents in commands.

My script is like this.

Instead of printing the value in the commands file, it is simply printing $cmd in the output file.

Any pointers are highly appreciated.

#!/bin/ksh
n=1 
while read -r cmd
do      (sed 's/hello/"$cmd"/' input) > input$n
        n=$((n + 1))
done < commands
(sed "s/hello/${cmd}/" input) > input$n
1 Like