在 Windows 7 机器上,对于给定扩展名的文件,我想要一种快速的方法来确定目录树中所有文件的行数。有什么好的开箱即用的方法来做到这一点吗?
小智 62
您可以Measure-Object像这样在 powershell 中使用:
PS D:\temp> dir -Recurse *.txt | Get-Content | Measure-Object -Line
Run Code Online (Sandbox Code Playgroud)
这将返回以下内容:
Lines Words Characters Property
----- ----- ---------- --------
168
Run Code Online (Sandbox Code Playgroud)
小智 8
要扩展上面的 maweeras 答案(抱歉没有足够的代表来评论),您可以通过将逗号分隔的数组传递给 -Include 来搜索多个文件扩展名。
例如:
dir -Recurse -Include *.ts,*.tsx -Exclude *node_modules* | Get-Content | Measure-Object -Line
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
64033 次 |
| 最近记录: |