LoginSignup
0
0

More than 3 years have passed since last update.

再帰してディレクトリ内のファイルの行数を個別に表示する

Last updated at Posted at 2019-10-02

末尾が _spec のファイルは除外している

# 全ファイルの行数を吐き出すlinuxコマンド (rubyはバッククォートにするとシェルを直接実行できる)
`for file in $(find . -name "*.rb"); do wc -l $file; done > ./tmp/lines.txt`
  open('./tmp/lines.txt', 'r') { |f| f.inject([]) { |r, l| r << l.split(" ") } }.sort{|a, b| a[0].to_i <=> b[0].to_i }.each {|i| puts i.join(" : ") unless i[1] =~ /_spec/  }

よくよく考えたらシェル使わずに Dir.glob でパス取ってきてやるでもよかったな...

0
0
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0