Remove trailing whitespace from each line.
Section: sed and Stream Editing
Trim trailing spaces
bash
bash
sed -E 's/[[:space:]]+$//' file.txtExplanation
Useful before committing source files.
Learn the surrounding workflow
Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.
Related commands
Same sheet · prioritizing sed and Stream Editing