Are there any tools / UNIX single liners which would remove trailing whitespaces for multiple files in-place.
E.g. one that could be used in the conjunction with find.
Are there any tools / UNIX single liners which would remove trailing whitespaces for multiple files in-place.
E.g. one that could be used in the conjunction with find.
For some reason, the sed and perl commands did not work for me. This did :
Feels like the most straight forward one to read as well
How about this:
Btw, this is a handy site: http://sed.sourceforge.net/sed1line.txt
Unlike other solutions which all require GNU sed, this one should work on any Unix system implementing POSIX standard commands.
Edit: this slightly modified version preserves the files permissions:
ex
Try using Ex editor (part of Vim):
Note: For recursion (bash4 & zsh), you can use a new globbing option (
**/*.*
). Enable byshopt -s globstar
.perl
as per Spring Framework Code Style.
sed
For using
sed
, check: How to remove trailing whitespaces with sed?See also: How to remove trailing whitespace of all files recursively?
For those that are not sed gurus (myself included) I have created a small script to use JavaScript regular expressions to replace text in files and does the replacement in place:
http://git.io/pofQnQ
To remove trailing whitespace you can use it as such:
Enjoy
I've been using this to fix whitespace:
Features:
[:space:]
), so it works fine on Windows/DOS-style files.file
thinks is a text file.