Skip to content

Instantly share code, notes, and snippets.

@Erikdegroot89
Last active January 14, 2020 13:44
Show Gist options
  • Save Erikdegroot89/d9a7e1efec12ac65e567e4b1fc13fc1e to your computer and use it in GitHub Desktop.
Save Erikdegroot89/d9a7e1efec12ac65e567e4b1fc13fc1e to your computer and use it in GitHub Desktop.
Shell script that echo's all files larger than 2 MB.
#/bin/sh
# Iterate given directory echoes every file that's larger than 2MB
# See also https://explainshell.com/explain?cmd=find+.%2F+-maxdepth+2+-size+%2B2M
find $1 -maxdepth 2 -size +2M | while read file;
do
FILESIZE=$(stat -c%s "$file")
echo "$file is too large: ($FILESIZE)"
# add any scripts you'd want to call here
done
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment