Strip Trailing Whitespace from Git projects =========================================== A common linting error thrown by various linters is for trailing whitespace. I most often use flake8. I generally have pre-commit hooks setup to strip this,... Date: September 30, 2020 A common linting error thrown by various linters is for trailing whitespace. I most often use flake8. I generally have [pre-commit]([https://waylonwalker.com/pre-commit-is-awesome](https://waylonwalker.com/pre-commit-is-awesome/) hooks setup to strip this, but sometimes I run into situations where I jump into a project without it, and my editor lights up with errors. A simple fix is to run this one-liner. ## One-Liner to strip whitespace _bash_ ``` bash git grep -I --name-only -z -e '' | xargs -0 sed -i -e 's/[ \t]\+\(\r\?\)$/\1/' ``` [1] read more about how pre-commit is awesome [2] References: [1]: https://waylonwalker.com/pre-commit-is-awesome [2]: /pre-commit-is-awesome/