title: Bash: Remove ALL special characters from end of variable (not just CR or LF)
body: <p>I have some text files and getting the first line(s) into a variable using <code>var=$(head -n 1 &quot;$@&quot;)</code>, however the variable contains special charaters that I want removed (ASCII 1-31).</p>
  <p>Is there a quick way to strip the end of a variable from ASCII codes 1-31? I've used <code>${var//[^[:ascii:]]/}</code> and <code>var=&quot;${var//[$'\t\r\n']}&quot;</code> already, however I need ASCII 1-31 removed from the end in a simple way (not just CF/LF/Tab/FF/etc.).</p>