0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

PowerShellでディレクトリ内のファイルの総行数を入手するワンライナー

Posted at

ディレクトリ内のプログラムコードの総行数を数えてと言われて、手作業で数えたくなかったのでワンライナーした

ワンライナー

 (Get-ChildItem -Recurse <ディレクトリパス> -include <ファイル名> | % {(Get-Content -Path $_).Length} | M
easure-Object -Sum).Sum

具体例

> (Get-ChildItem -Recurse .\ -include *.cpp | % {(Get-Content -Path $_).Length} | M
easure-Object -Sum).Sum
> 1203

ファイル拡張子が複数あるときは-include *.cpp,*.cのように,(カンマ)で区切るといけます

0
1
0

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
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?