SyntaxFix
Write A Post
Hire A Developer
Questions
With bash 4.2 and newer you can use something like this to strip the trailing CR, which only uses bash built-ins:
if [[ "${str: -1}" == $'\r' ]]; then str="${str:: -1}" fi