The answer to removing trailing whitespace with sed has most of the answer, but I want
sed -i 's/[ \t]*$//' $1
to be able to take arbitrary number of file arguments as a shell script on the command line, including glob arguments. I.e. suppose the script is called strip_trailing_whitespace
. Then I'd like to be able to do both
strip_trailing_whitespace foo.cc bar.cc
and
strip_trailing_whitespace *.cc *.hh
to strip trailing whitespaces from all files of the form *.cc
and *.hh
. Arguments not based on the answer quoted above are also fine.