du calculating whole directory size when we pipe the null input, how to stop it

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
0
down vote

favorite












[emdfqmm@nfwne ncndnkln]$ ll -h | grep "Oct" | grep "2018" | xargs du -ch
5.0G ./something
5.0G .
5.0G total

[emdfqmm@nfwne ncndnkln]$ ll -h | grep "Oct" | grep "2018" | wc -l
0


When it got null input its calculating the whole directory size how to stop it










share|improve this question









New contributor




user322121 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.















  • 1




    I don't think any part of your command is doing what you want it to do. This seems like an XY Problem. Can you please redo your question to ask what your goal is and I'm sure someone can help you find the correct solution.
    – Jesse_b
    Nov 21 at 15:01














up vote
0
down vote

favorite












[emdfqmm@nfwne ncndnkln]$ ll -h | grep "Oct" | grep "2018" | xargs du -ch
5.0G ./something
5.0G .
5.0G total

[emdfqmm@nfwne ncndnkln]$ ll -h | grep "Oct" | grep "2018" | wc -l
0


When it got null input its calculating the whole directory size how to stop it










share|improve this question









New contributor




user322121 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.















  • 1




    I don't think any part of your command is doing what you want it to do. This seems like an XY Problem. Can you please redo your question to ask what your goal is and I'm sure someone can help you find the correct solution.
    – Jesse_b
    Nov 21 at 15:01












up vote
0
down vote

favorite









up vote
0
down vote

favorite











[emdfqmm@nfwne ncndnkln]$ ll -h | grep "Oct" | grep "2018" | xargs du -ch
5.0G ./something
5.0G .
5.0G total

[emdfqmm@nfwne ncndnkln]$ ll -h | grep "Oct" | grep "2018" | wc -l
0


When it got null input its calculating the whole directory size how to stop it










share|improve this question









New contributor




user322121 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











[emdfqmm@nfwne ncndnkln]$ ll -h | grep "Oct" | grep "2018" | xargs du -ch
5.0G ./something
5.0G .
5.0G total

[emdfqmm@nfwne ncndnkln]$ ll -h | grep "Oct" | grep "2018" | wc -l
0


When it got null input its calculating the whole directory size how to stop it







linux disk-usage xargs






share|improve this question









New contributor




user322121 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|improve this question









New contributor




user322121 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this question




share|improve this question








edited Nov 21 at 21:49









Jeff Schaller

36.6k1052121




36.6k1052121






New contributor




user322121 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked Nov 21 at 14:52









user322121

1




1




New contributor




user322121 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





user322121 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






user322121 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.







  • 1




    I don't think any part of your command is doing what you want it to do. This seems like an XY Problem. Can you please redo your question to ask what your goal is and I'm sure someone can help you find the correct solution.
    – Jesse_b
    Nov 21 at 15:01












  • 1




    I don't think any part of your command is doing what you want it to do. This seems like an XY Problem. Can you please redo your question to ask what your goal is and I'm sure someone can help you find the correct solution.
    – Jesse_b
    Nov 21 at 15:01







1




1




I don't think any part of your command is doing what you want it to do. This seems like an XY Problem. Can you please redo your question to ask what your goal is and I'm sure someone can help you find the correct solution.
– Jesse_b
Nov 21 at 15:01




I don't think any part of your command is doing what you want it to do. This seems like an XY Problem. Can you please redo your question to ask what your goal is and I'm sure someone can help you find the correct solution.
– Jesse_b
Nov 21 at 15:01










2 Answers
2






active

oldest

votes

















up vote
0
down vote













xargs has an option to not run if no input is given:



-r, --no-run-if-empty
If the standard input does not contain any nonblanks, do not run
the command. Normally, the command is run once even if there is
no input. This option is a GNU extension.


So use xargs -r du -ch instead.






share|improve this answer








New contributor




Bash bros is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
























    up vote
    0
    down vote













    Use find with -exec:



    month="Oct-2018";
    find . -mindepth 1 -maxdepth 1 -newermt "01-$month -1 sec" -and -not -newermt "01-$month +1 month -1 sec" -exec du -ch ;


    Though, somehow I believe, you want du -sh instead of du -ch.



    See



    • Why *not* parse `ls` (and what do to instead)?

    • UNIX / BASH: Listing files modified in specific month





    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',
      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
      );



      );






      user322121 is a new contributor. Be nice, and check out our Code of Conduct.









       

      draft saved


      draft discarded


















      StackExchange.ready(
      function ()
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f483228%2fdu-calculating-whole-directory-size-when-we-pipe-the-null-input-how-to-stop-it%23new-answer', 'question_page');

      );

      Post as a guest















      Required, but never shown

























      2 Answers
      2






      active

      oldest

      votes








      2 Answers
      2






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes








      up vote
      0
      down vote













      xargs has an option to not run if no input is given:



      -r, --no-run-if-empty
      If the standard input does not contain any nonblanks, do not run
      the command. Normally, the command is run once even if there is
      no input. This option is a GNU extension.


      So use xargs -r du -ch instead.






      share|improve this answer








      New contributor




      Bash bros is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.





















        up vote
        0
        down vote













        xargs has an option to not run if no input is given:



        -r, --no-run-if-empty
        If the standard input does not contain any nonblanks, do not run
        the command. Normally, the command is run once even if there is
        no input. This option is a GNU extension.


        So use xargs -r du -ch instead.






        share|improve this answer








        New contributor




        Bash bros is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.



















          up vote
          0
          down vote










          up vote
          0
          down vote









          xargs has an option to not run if no input is given:



          -r, --no-run-if-empty
          If the standard input does not contain any nonblanks, do not run
          the command. Normally, the command is run once even if there is
          no input. This option is a GNU extension.


          So use xargs -r du -ch instead.






          share|improve this answer








          New contributor




          Bash bros is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
          Check out our Code of Conduct.









          xargs has an option to not run if no input is given:



          -r, --no-run-if-empty
          If the standard input does not contain any nonblanks, do not run
          the command. Normally, the command is run once even if there is
          no input. This option is a GNU extension.


          So use xargs -r du -ch instead.







          share|improve this answer








          New contributor




          Bash bros is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
          Check out our Code of Conduct.









          share|improve this answer



          share|improve this answer






          New contributor




          Bash bros is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
          Check out our Code of Conduct.









          answered Nov 21 at 15:04









          Bash bros

          1




          1




          New contributor




          Bash bros is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
          Check out our Code of Conduct.





          New contributor





          Bash bros is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
          Check out our Code of Conduct.






          Bash bros is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
          Check out our Code of Conduct.






















              up vote
              0
              down vote













              Use find with -exec:



              month="Oct-2018";
              find . -mindepth 1 -maxdepth 1 -newermt "01-$month -1 sec" -and -not -newermt "01-$month +1 month -1 sec" -exec du -ch ;


              Though, somehow I believe, you want du -sh instead of du -ch.



              See



              • Why *not* parse `ls` (and what do to instead)?

              • UNIX / BASH: Listing files modified in specific month





              share|improve this answer
























                up vote
                0
                down vote













                Use find with -exec:



                month="Oct-2018";
                find . -mindepth 1 -maxdepth 1 -newermt "01-$month -1 sec" -and -not -newermt "01-$month +1 month -1 sec" -exec du -ch ;


                Though, somehow I believe, you want du -sh instead of du -ch.



                See



                • Why *not* parse `ls` (and what do to instead)?

                • UNIX / BASH: Listing files modified in specific month





                share|improve this answer






















                  up vote
                  0
                  down vote










                  up vote
                  0
                  down vote









                  Use find with -exec:



                  month="Oct-2018";
                  find . -mindepth 1 -maxdepth 1 -newermt "01-$month -1 sec" -and -not -newermt "01-$month +1 month -1 sec" -exec du -ch ;


                  Though, somehow I believe, you want du -sh instead of du -ch.



                  See



                  • Why *not* parse `ls` (and what do to instead)?

                  • UNIX / BASH: Listing files modified in specific month





                  share|improve this answer












                  Use find with -exec:



                  month="Oct-2018";
                  find . -mindepth 1 -maxdepth 1 -newermt "01-$month -1 sec" -and -not -newermt "01-$month +1 month -1 sec" -exec du -ch ;


                  Though, somehow I believe, you want du -sh instead of du -ch.



                  See



                  • Why *not* parse `ls` (and what do to instead)?

                  • UNIX / BASH: Listing files modified in specific month






                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Nov 21 at 15:07









                  RoVo

                  2,224215




                  2,224215




















                      user322121 is a new contributor. Be nice, and check out our Code of Conduct.









                       

                      draft saved


                      draft discarded


















                      user322121 is a new contributor. Be nice, and check out our Code of Conduct.












                      user322121 is a new contributor. Be nice, and check out our Code of Conduct.











                      user322121 is a new contributor. Be nice, and check out our Code of Conduct.













                       


                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function ()
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f483228%2fdu-calculating-whole-directory-size-when-we-pipe-the-null-input-how-to-stop-it%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

                      How to check contact read email or not when send email to Individual?

                      Bahrain

                      Postfix configuration issue with fips on centos 7; mailgun relay