How to remove trailing whitespace of all files recursively?

前端 未结 15 1995
难免孤独
难免孤独 2020-12-07 06:58

How can you remove all of the trailing whitespace of an entire project? Starting at a root directory, and removing the trailing whitespace from all files in all folders.

15条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-07 07:57

    Ruby:

    irb
    Dir['lib/**/*.rb'].each{|f| x = File.read(f); File.write(f, x.gsub(/[ \t]+$/,"")) }
    

提交回复
热议问题