如何在目录结构中找到 10 个最大的文件 [英] How do I find the 10 largest files in a directory structure

查看:70
本文介绍了如何在目录结构中找到 10 个最大的文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何找到目录结构中最大的 10 个文件?

How do I find the 10 largest files in a directory structure?

推荐答案

试试这个脚本

Get-ChildItem -re -in * |
  ?{ -not $_.PSIsContainer } |
  sort Length -descending |
  select -first 10

细分:

过滤器块?{ -not $_.PSIsContainer }"用于过滤目录.sort 命令将按大小降序对所有剩余条目进行排序.select 子句将只允许前 10 个通过,因此它将是最大的 10 个.

The filter block "?{ -not $_.PSIsContainer }" is meant to filter out directories. The sort command will sort all of the remaining entries by size in descending order. The select clause will only allow the first 10 through so it will be the largest 10.

这篇关于如何在目录结构中找到 10 个最大的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆