您的位置:首页 > 运维架构 > Linux

Linux下指定目录中最大的10个文件

2017-10-18 17:45 267 查看
$all_file = array();
function get_max_file($dir) {
$list = scandir($dir);
foreach ( $list as $file ) {
$file_location = $dir . '/' . $file;
if ( is_dir($file_location) && $file != "." && $file != ".." ) {
get_max_file($file_location);
} elseif ( $file_location ) {
if ( $file != '.' && $file != '..' ) {
$file_size = filesize($file_location);
$GLOBALS['all_file'][$file_location] = $file_size;
}
}
}
}
get_max_file('./');
arsort($all_file);
$max_size = array_slice($all_file, 0, 10);
var_dump($max_size);
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: