I am trying to read a variable value from test.sh and write it in file2.txt by replacing the word COMP in file2.txt
I am using below command to achieve this but not possible
sed -r 's/(echo "$NAME" test.sh)/COMP/' file2.txt
for your reference
test.sh contains
#!/bin/bash
NAME=RAJ