sort files greater than 1000 bytes in descending order

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











up vote
0
down vote

favorite












I can sort the files either in descending order (of any size) or list all files greater than 1000 bytes but don't know how to sort files greater than 1000 bytes in a user specified directory.



List files greater than 1000 bytes :



for i in "$1/*" # $1 expects a directory name
do
if [ `wc -c $i` -gt 1000 ]
echo $i
done


List files in descending order of size :



`ls -lhS`


But how do I list all files greater than 1000 bytes in descending order of size?










share|improve this question

























    up vote
    0
    down vote

    favorite












    I can sort the files either in descending order (of any size) or list all files greater than 1000 bytes but don't know how to sort files greater than 1000 bytes in a user specified directory.



    List files greater than 1000 bytes :



    for i in "$1/*" # $1 expects a directory name
    do
    if [ `wc -c $i` -gt 1000 ]
    echo $i
    done


    List files in descending order of size :



    `ls -lhS`


    But how do I list all files greater than 1000 bytes in descending order of size?










    share|improve this question























      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite











      I can sort the files either in descending order (of any size) or list all files greater than 1000 bytes but don't know how to sort files greater than 1000 bytes in a user specified directory.



      List files greater than 1000 bytes :



      for i in "$1/*" # $1 expects a directory name
      do
      if [ `wc -c $i` -gt 1000 ]
      echo $i
      done


      List files in descending order of size :



      `ls -lhS`


      But how do I list all files greater than 1000 bytes in descending order of size?










      share|improve this question













      I can sort the files either in descending order (of any size) or list all files greater than 1000 bytes but don't know how to sort files greater than 1000 bytes in a user specified directory.



      List files greater than 1000 bytes :



      for i in "$1/*" # $1 expects a directory name
      do
      if [ `wc -c $i` -gt 1000 ]
      echo $i
      done


      List files in descending order of size :



      `ls -lhS`


      But how do I list all files greater than 1000 bytes in descending order of size?







      shell-script bourne-shell






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Sep 27 '17 at 5:17









      Mayank Kumar

      1031




      1031




















          1 Answer
          1






          active

          oldest

          votes

















          up vote
          3
          down vote



          accepted










          Try this:



          find . -maxdepth 1 -size +1000c -type f -exec ls -lhSa '' +


          Explanation:



          -maxdepth 1 - find files only in current directory



          -size +1000c - find only files greather than 1000 bytes ("c" = bytes)



          -type f - find only files



          -exec <command> + - execute command. See man find for more information



          If you do not want to use find (i don't know why), you may type (thx @αғsнιη):



          ls -lpSa | awk '! /// && $5>1000'


          But Why not parse ls?






          share|improve this answer






















          • No need grep here, you can get it with awk itself ls -lpSa| awk '! /// && $5>1000' + Please don't parse ls output.
            – Î±Ò“sнιη
            Sep 27 '17 at 7:39











          • @αғsнιη thx alot. I added this into a post
            – Egor Vasilyev
            Sep 27 '17 at 7:46










          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: false,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          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%2f394672%2fsort-files-greater-than-1000-bytes-in-descending-order%23new-answer', 'question_page');

          );

          Post as a guest






























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          up vote
          3
          down vote



          accepted










          Try this:



          find . -maxdepth 1 -size +1000c -type f -exec ls -lhSa '' +


          Explanation:



          -maxdepth 1 - find files only in current directory



          -size +1000c - find only files greather than 1000 bytes ("c" = bytes)



          -type f - find only files



          -exec <command> + - execute command. See man find for more information



          If you do not want to use find (i don't know why), you may type (thx @αғsнιη):



          ls -lpSa | awk '! /// && $5>1000'


          But Why not parse ls?






          share|improve this answer






















          • No need grep here, you can get it with awk itself ls -lpSa| awk '! /// && $5>1000' + Please don't parse ls output.
            – Î±Ò“sнιη
            Sep 27 '17 at 7:39











          • @αғsнιη thx alot. I added this into a post
            – Egor Vasilyev
            Sep 27 '17 at 7:46














          up vote
          3
          down vote



          accepted










          Try this:



          find . -maxdepth 1 -size +1000c -type f -exec ls -lhSa '' +


          Explanation:



          -maxdepth 1 - find files only in current directory



          -size +1000c - find only files greather than 1000 bytes ("c" = bytes)



          -type f - find only files



          -exec <command> + - execute command. See man find for more information



          If you do not want to use find (i don't know why), you may type (thx @αғsнιη):



          ls -lpSa | awk '! /// && $5>1000'


          But Why not parse ls?






          share|improve this answer






















          • No need grep here, you can get it with awk itself ls -lpSa| awk '! /// && $5>1000' + Please don't parse ls output.
            – Î±Ò“sнιη
            Sep 27 '17 at 7:39











          • @αғsнιη thx alot. I added this into a post
            – Egor Vasilyev
            Sep 27 '17 at 7:46












          up vote
          3
          down vote



          accepted







          up vote
          3
          down vote



          accepted






          Try this:



          find . -maxdepth 1 -size +1000c -type f -exec ls -lhSa '' +


          Explanation:



          -maxdepth 1 - find files only in current directory



          -size +1000c - find only files greather than 1000 bytes ("c" = bytes)



          -type f - find only files



          -exec <command> + - execute command. See man find for more information



          If you do not want to use find (i don't know why), you may type (thx @αғsнιη):



          ls -lpSa | awk '! /// && $5>1000'


          But Why not parse ls?






          share|improve this answer














          Try this:



          find . -maxdepth 1 -size +1000c -type f -exec ls -lhSa '' +


          Explanation:



          -maxdepth 1 - find files only in current directory



          -size +1000c - find only files greather than 1000 bytes ("c" = bytes)



          -type f - find only files



          -exec <command> + - execute command. See man find for more information



          If you do not want to use find (i don't know why), you may type (thx @αғsнιη):



          ls -lpSa | awk '! /// && $5>1000'


          But Why not parse ls?







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Sep 27 '17 at 7:44

























          answered Sep 27 '17 at 5:34









          Egor Vasilyev

          1,792129




          1,792129











          • No need grep here, you can get it with awk itself ls -lpSa| awk '! /// && $5>1000' + Please don't parse ls output.
            – Î±Ò“sнιη
            Sep 27 '17 at 7:39











          • @αғsнιη thx alot. I added this into a post
            – Egor Vasilyev
            Sep 27 '17 at 7:46
















          • No need grep here, you can get it with awk itself ls -lpSa| awk '! /// && $5>1000' + Please don't parse ls output.
            – Î±Ò“sнιη
            Sep 27 '17 at 7:39











          • @αғsнιη thx alot. I added this into a post
            – Egor Vasilyev
            Sep 27 '17 at 7:46















          No need grep here, you can get it with awk itself ls -lpSa| awk '! /// && $5>1000' + Please don't parse ls output.
          – Î±Ò“sнιη
          Sep 27 '17 at 7:39





          No need grep here, you can get it with awk itself ls -lpSa| awk '! /// && $5>1000' + Please don't parse ls output.
          – Î±Ò“sнιη
          Sep 27 '17 at 7:39













          @αғsнιη thx alot. I added this into a post
          – Egor Vasilyev
          Sep 27 '17 at 7:46




          @αғsнιη thx alot. I added this into a post
          – Egor Vasilyev
          Sep 27 '17 at 7:46

















           

          draft saved


          draft discarded















































           


          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f394672%2fsort-files-greater-than-1000-bytes-in-descending-order%23new-answer', 'question_page');

          );

          Post as a guest













































































          Popular posts from this blog

          Peggy Mitchell

          Palaiologos

          The Forum (Inglewood, California)