Shell script to find largest PNG files in directory recursively
The following shell script finds the largest PNG files in a directory recursively and prints their sizes in human-readable format:
find_largest_pngs.sh
find . -iname "*.png" -type f -exec du -h {} + | sort -rh | head -nwhere:
find . -iname "*.png"searches for all PNG (case-insensitive:.pngor.PNGetc) files in the current directory (.) and subdirectories-type fensures that only files are considered (not directories)-exec du -h {} +executes theducommand on each found file, printing their sizes in human-readable formatsort -rhsorts the output in reverse order by sizehead -nlimits the output to the topnlargest files
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