SyntaxFix
Write A Post
Hire A Developer
Questions
This might work for you (GNU sed):
sed -ri '/\s+$/s///' file
This looks for whitespace at the end of the line and and if present removes it.