Parameter substitution is not working with sed

I am trying add a prefix variable(string) to command output.
sed parameter substitution is not working.

  • I have found some issues on my end of testing,, please delete this thread for now.

You define a variable named prefix . You expand a variable named myprefix . Try:

prefix='myprefix'; echo "chr, aaaaa|bbbbbb" | sed "s/^/$prefix,/"

which produces the output:

myprefix,chr, aaaaa|bbbbbb
1 Like