Most obvious here would be to use sed:
To substitute it with nothing wouldthat string when found at the end of the line $ which we escape as \$ for the shell (to be future proof in case $/ means something in the most obviousshell in the future).
To also remove whatever follows that string if any, replace the \$ with .*, though we'd need to change the locale the C to guarantee .* matches everything up to the end even if that's not valid text in the user's locale:
<source LC_ALL=C sed "s/, characters I don't want.*//"
<source LC_ALL=C grep -Po "^.*?(?=(, characters I don't want)?\$)"
Or to remove everything if any after that string as well:
<source LC_ALL=C grep -Po "^.*?(?=, characters I don't want|\$)"
Or to remove everything if any after that string as well:
<source pcregrep -o1 "^(.*?)(, characters I don't want|\$)"
If the text to remove may contain anything including / or regex operators (but not newline characters which wouldn't make sense, nor NUL characters which can be passed in command arguments nor environment variables) and is stored in a shell variable, you do not want to use as that would make it a command injection vulnerability.sed "s/$string\$//"
string='/.*\^$'
<source LC_ALL=C grep -Po "^.*?(?=(\Q$string)?\$)"
<source pcregrep -o1 "^(.*?)\Q$string\E\$"(\Q$string\E)?\$"
Or to remove everything if any after that string as well:
<source LC_ALL=C grep -Po "^.*?(?=\Q$string|\$)"
<source pcregrep -o1 "^(.*?)(\Q$string\E|\$)"
Or to remove everything if any after that string as well:
<source perl -spe 's/\Q$string\E.*$//' -- -string="$string"
perl treats input as bytes not as if encoded in the user's locale charset by default, so we don't need to change the locale there.