Last active
August 26, 2024 18:40
-
-
Save thebouv/8657674 to your computer and use it in GitHub Desktop.
ducks: linux command for the 10 largest files in current directory
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
du -cks * | sort -rn | head -11 | |
# Usually set this up in my bash profile as an alias: | |
# alias ducks='du -cks * | sort -rn | head -11' | |
# Because it is fun to type ducks on the command line. :) |
alias ducks='du -cks $(ls -A) | sort -rn | head -n11'
will search in hidden directories also. Helpful for large caches.
@georgedorn you're right -- I use this now:
alias ducks='while read -r line;do du -sh "$line";done < <(ls -1A) | sort -rh | head -n11'
Thanks for the improvement
If this is for the current directory, why not du -cks
without further arguments? No parsing ls
or shell globbing necessary.
@mcguirepr89 this fails on folders with spaces in the name.
@thebouv I'd use du -cksx
if there are any symlinks or sshfs mounts into large networked filesystem, like a NAS...
Suddenly wondering why this has got attention when I posted it in 2014. Weird.
@georgedorn Yeah guess it’s just never come up. 🤷🏼♂️
I saw it linked on Mastodon.
I saw it linked on Mastodon.
Hah! Neat.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This script has helped me so much.