I thought so.
If we can determine exactly what the offending character is, we can probably use
parameter substitution instead of sed. I'm pretty sure it's the tab. So try using this:
Code:
var2="${var2//$'\t'/ }"
This should replace all tabs with spaces. Or to simulate your actual sed command using the control character set:
Code:
var2="$var2//[[:cntrl:]]/ }"
There's also a tool called
uniname, part of the uniutils package, that can be used to learn exactly what every character in a text string is. So if it isn't the tab, try piping it through that.
PS: In the future, please use [code][/code] tags around your code, to preserve formatting and to improve readability.