Code Monkey home page Code Monkey logo

Comments (5)

Grimy avatar Grimy commented on May 16, 2024

I prefer du -skc * | sort -n. Human-readable output is nice, but not really pipe-friendly.

Ideally we would have a “humanify” or “hs” command, allowing us to do du -sbc * | sort -n | hs. That’s actually rather easy to implement: alias hs='perl -pe "s;\d\K(\d{3})+\b;qw(k M G T P)[\$&=~y///c/3-1];e"' will do the trick (most of the time — I literally just whipped this in five minutes without caring for edge cases).

from the-art-of-command-line.

tombrus avatar tombrus commented on May 16, 2024

For sorting you can use -h as well: du -sh * | sort -h.

Current Ubuntu at least, not supported on my Mac though 😢

from the-art-of-command-line.

Grimy avatar Grimy commented on May 16, 2024

Ooh, thanks, I didn’t know about sort -h. It’s not in POSIX, so I imagine it’s a GNU extension.

from the-art-of-command-line.

tombrus avatar tombrus commented on May 16, 2024

Good to help! As said, there is always something to learn. These sort of write-ups are a great help for that, and fun to read! Thanks!

from the-art-of-command-line.

jlevy avatar jlevy commented on May 16, 2024

👍 Thanks @tombrus and all for the discussion. I think this is an improvement.

from the-art-of-command-line.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.