Shell 脚本:递归查找目录中最大的 PNG 文件
以下 shell 脚本递归查找目录中最大的 PNG 文件,并以人类可读格式打印其大小:
find_largest_pngs.sh
find . -iname "*.png" -type f -exec du -h {} + | sort -rh | head -n其中:
find . -iname "*.png"在当前目录(.)和子目录中搜索所有 PNG(不区分大小写:.png或.PNG等)文件-type f确保只考虑文件(不包括目录)-exec du -h {} +对每个找到的文件执行du命令,以人类可读格式打印其大小sort -rh按大小逆序排序输出head -n将输出限制为前n个最大文件
Check out similar posts by category:
Linux
If this post helped you, please consider buying me a coffee or donating via PayPal to support research & publishing of new posts on TechOverflow