How to remove trailing whitespaces for multiple files?

前端 未结 7 906
长发绾君心
长发绾君心 2020-12-12 14:04

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 con

7条回答
  •  不思量自难忘°
    2020-12-12 14:55

    ex

    Try using Ex editor (part of Vim):

    $ ex +'bufdo!%s/\s\+$//e' -cxa *.*
    

    Note: For recursion (bash4 & zsh), you can use a new globbing option (**/*.*). Enable by shopt -s globstar.

    perl

    find . -type f -name "*.java" -exec perl -p -i -e "s/[ \t]$//g" {} \;
    

    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?

提交回复
热议问题