如何按文件大小排序查找结果 [英] How sort find result by file sizes

查看:127
本文介绍了如何按文件大小排序查找结果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何按文件大小对find命令的结果进行排序?

How can I sort by file size the results of the find command?

我试图对以下find命令的结果进行排序:

I trying to sort the result of this find command:

find ./src -type f -print0

我不需要目录的大小,我只需要按大小对文件相对路径进行排序.

I don't want the size of directories, I need the files relative paths sorted by size only.

推荐答案

以下是使用find命令的方法:

Here is how to do using find command:

find . -type f -exec ls -al {} \; | sort -k 5 -n | sed 's/ \+/\t/g' | cut -f 9

以下是使用递归ls命令的方法:

Here is how to do using recursive ls command:

ls -lSR | sort -k 5 -n

或者,如果您只想显示文件名:

Or, if you want to display only file names:

ls -lSR | sort -k 5 -n | sed 's/ \+/\t/g' | cut -f 9

这篇关于如何按文件大小排序查找结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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