Расширение параметров оболочкии использование синтаксиса удаления подстроки
${parameter%word}
/Substring Expansion ${parameter:offset:length}
.
"${line%??}" # strip the shortest suffix pattern match the word
"${line::-2}" # strip last 2 characters (`bash 4.2` and above)
"${line: : -2}" # in older you could add spaces between OR
"${line::${#line}-2}"