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.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You want
That will delete all POSIX standard defined whitespace characters, including vertical tab and form feed. Also, it will only do a replacement if the trailing whitespace actually exists, unlike the other answers that use the zero or more matcher (
*).--in-placeis simply the long form of-i. I prefer to use the long form in scripts because it tends to be more illustrative of what the flag actually does.It can be easily integrated with
findlike so:If you’re on a Mac
As pointed out in the comments, the above doesn’t work if you don’t have gnu tools installed. If that’s the case, you can use the following: