du -sh * , hide directories with 0 usage The 2019 Stack Overflow Developer Survey Results Are...

Which Sci-Fi work first showed weapon of galactic-scale mass destruction?

How to answer pointed "are you quitting" questioning when I don't want them to suspect

How to deal with fear of taking dependencies

How to change the limits of integration

Limit the amount of RAM Mathematica may access?

Inflated grade on resume at previous job, might former employer tell new employer?

Are USB sockets on wall outlets live all the time, even when the switch is off?

Is bread bad for ducks?

How can I create a character who can assume the widest possible range of creature sizes?

Does it makes sense to buy a new cycle to learn riding?

Output the Arecibo Message

How can I fix this gap between bookcases I made?

On the insanity of kings as an argument against monarchy

Inline version of a function returns different value than non-inline version

Is domain driven design an anti-SQL pattern?

Lethal sonic weapons

Is three citations per paragraph excessive for undergraduate research paper?

What is the motivation for a law requiring 2 parties to consent for recording a conversation

How to make payment on the internet without leaving a money trail?

Why isn't airport relocation done gradually?

What does "rabbited" mean/imply in this sentence?

How are circuits which use complex ICs normally simulated?

What is the best strategy for white in this position?

I see my dog run



du -sh * , hide directories with 0 usage



The 2019 Stack Overflow Developer Survey Results Are InDiscrepancy between reported used memory and sum of application memory usageProblem when trying to cross-compile an ethernet driver on an old Linux kernelSetup public IP address on LXC containerHow to read the output of the show-memory-usage SysRq?delete all empty directories starting withsort File B based on column 3 of File A without changing contents of File AMySQL High Ram Usage?I am looking for a built-in (simple) command to show network usage and bandwidthCompare two arrays with their respective directories in shell script?Sort with field separator





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom:0;
}







1















Here's what my current output looks like.



475M    directorya
0 directoryb
0 directoryc
520M directoryd
42G somefolder


Here is what I am trying to do.




  1. How do I hide the directories with 0 usage? Essentially only show directories with >0.

  2. How do I sort this in ascending / descending ordedr?










share|improve this question





























    1















    Here's what my current output looks like.



    475M    directorya
    0 directoryb
    0 directoryc
    520M directoryd
    42G somefolder


    Here is what I am trying to do.




    1. How do I hide the directories with 0 usage? Essentially only show directories with >0.

    2. How do I sort this in ascending / descending ordedr?










    share|improve this question

























      1












      1








      1


      1






      Here's what my current output looks like.



      475M    directorya
      0 directoryb
      0 directoryc
      520M directoryd
      42G somefolder


      Here is what I am trying to do.




      1. How do I hide the directories with 0 usage? Essentially only show directories with >0.

      2. How do I sort this in ascending / descending ordedr?










      share|improve this question














      Here's what my current output looks like.



      475M    directorya
      0 directoryb
      0 directoryc
      520M directoryd
      42G somefolder


      Here is what I am trying to do.




      1. How do I hide the directories with 0 usage? Essentially only show directories with >0.

      2. How do I sort this in ascending / descending ordedr?







      linux






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked yesterday









      NishantNishant

      213




      213






















          1 Answer
          1






          active

          oldest

          votes


















          2














          du -sh /directory/* | awk '$1 != "0" {print $0}' | sort -h


          The output of du -sh /directory/* will show the the size of the directories contained therein in the first column and the directories themselves in the second column.



          The above command runs du -sh on the directory and then tells awk to print only the lines where the first column (the size) is not equal to 0 and to then sort the output in human readable order.






          share|improve this answer
























            Your Answer








            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "106"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: false,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: null,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f511332%2fdu-sh-hide-directories-with-0-usage%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            2














            du -sh /directory/* | awk '$1 != "0" {print $0}' | sort -h


            The output of du -sh /directory/* will show the the size of the directories contained therein in the first column and the directories themselves in the second column.



            The above command runs du -sh on the directory and then tells awk to print only the lines where the first column (the size) is not equal to 0 and to then sort the output in human readable order.






            share|improve this answer




























              2














              du -sh /directory/* | awk '$1 != "0" {print $0}' | sort -h


              The output of du -sh /directory/* will show the the size of the directories contained therein in the first column and the directories themselves in the second column.



              The above command runs du -sh on the directory and then tells awk to print only the lines where the first column (the size) is not equal to 0 and to then sort the output in human readable order.






              share|improve this answer


























                2












                2








                2







                du -sh /directory/* | awk '$1 != "0" {print $0}' | sort -h


                The output of du -sh /directory/* will show the the size of the directories contained therein in the first column and the directories themselves in the second column.



                The above command runs du -sh on the directory and then tells awk to print only the lines where the first column (the size) is not equal to 0 and to then sort the output in human readable order.






                share|improve this answer













                du -sh /directory/* | awk '$1 != "0" {print $0}' | sort -h


                The output of du -sh /directory/* will show the the size of the directories contained therein in the first column and the directories themselves in the second column.



                The above command runs du -sh on the directory and then tells awk to print only the lines where the first column (the size) is not equal to 0 and to then sort the output in human readable order.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered yesterday









                Nasir RileyNasir Riley

                2,9972410




                2,9972410






























                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to Unix & Linux Stack Exchange!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f511332%2fdu-sh-hide-directories-with-0-usage%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Taj Mahal Inhaltsverzeichnis Aufbau | Geschichte | 350-Jahr-Feier | Heutige Bedeutung | Siehe auch |...

                    Baia Sprie Cuprins Etimologie | Istorie | Demografie | Politică și administrație | Arii naturale...

                    Nicolae Petrescu-Găină Cuprins Biografie | Opera | In memoriam | Varia | Controverse, incertitudini...