Find Text Files Containing Trailing Spaces
find . -iname "*.c" -or -iname "*.h" | xargs egrep -l ' +[[:cntrl:]]*$'
The expression [[:cntrl:]]*
is used to make sure this also works for
files with DOS/Windows line endings, i.e. a CR before the LF.
— Martin Burnicki martin.burnicki@burnicki.net, last updated 2023-04-17