On Ubuntu Studio 18 the $ error is due to bash expansion notice the errors when you run $0 vs $(0) vs $0
An alternative to seeking to the end of line in sed script is finding everything and using the & variable to append things after it; It's used like this:
$ echo "this was here" | sed -e 's_.*_& YOURFOOBAR_'
If you are learning sed script you can seek to front like home key with ^ and add multiple sed commands with ; character(s). Here I use _ or / interchangeably for the replacement sed script command 's///'
$ echo "this was here" | sed -e 's/^/PREFIXEDTEXT /;s_.*_& SUFFIXEDTEXT_'
NOTE:
Test command is aliased like so alias [=test so this make problems I think with bash Expansion. see man bash things like &| don't work.
Lastly, I suggest buying a book off ebay rather than trying to learn here.