Created
July 15, 2023 13:12
-
-
Save cdot65/736a740d965225503756a226c6a1d87c to your computer and use it in GitHub Desktop.
To iterate over all folders in your current directory, and display the sizes of files in each directory sorted by size, you can use the du and sort commands in Bash. The du command estimates file and directory space usage, while sort can sort lines in text files.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
for d in */ ; do | |
echo "Processing directory: $d" | |
find "$d" -type f -exec du -ah {} \; | sort -rh | head -n 10 | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment