Skip to content

Instantly share code, notes, and snippets.

@thebouv
Last active January 14, 2024 03:43
  • Star 33 You must be signed in to star a gist
  • Fork 6 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save thebouv/8657674 to your computer and use it in GitHub Desktop.
ducks: linux command for the 10 largest files in current directory
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. :)
@zchrissirhcz
Copy link

It would be better to use this:

du -sh * | sort -hr | head

@Sasino97
Copy link

This script has helped me so much.

@mcguirepr89
Copy link

mcguirepr89 commented Jan 25, 2022

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

@Goorzhel
Copy link

If this is for the current directory, why not du -cks without further arguments? No parsing ls or shell globbing necessary.

@georgedorn
Copy link

@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...

@thebouv
Copy link
Author

thebouv commented Jan 23, 2023

Suddenly wondering why this has got attention when I posted it in 2014. Weird.

@georgedorn Yeah guess it’s just never come up. 🤷🏼‍♂️

@Goorzhel
Copy link

I saw it linked on Mastodon.

@thebouv
Copy link
Author

thebouv commented Jan 23, 2023

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