How can I convert tabs to spaces in every file of a directory?

后端 未结 19 1283
既然无缘
既然无缘 2020-12-02 03:48

How can I convert tabs to spaces in every file of a directory (possibly recursively)?

Also, is there a way of setting the number of spaces per tab?

19条回答
  •  不思量自难忘°
    2020-12-02 03:56

    To convert all Java files recursively in a directory to use 4 spaces instead of a tab:

    find . -type f -name *.java -exec bash -c 'expand -t 4 {} > /tmp/stuff;mv /tmp/stuff {}' \;
    

提交回复
热议问题