Awk value greater than 40










0















Can someone please help me. I'm trying to get values greater than 40, but when it's at 100 it doesn't get it.



[root@localhost home]# df -Pk --block-size=1M

Filesystem 1048576-blocks Used Available Capacity Mounted on

/dev/mapper/rhel-root 22510 13135 9375 59% /

devtmpfs 905 0 905 0% /dev

tmpfs 920 1 920 1% /dev/shm

tmpfs 920 9 911 1% /run

tmpfs 920 0 920 0% /sys/fs/cgroup

/dev/sda1 1014 178 837 18% /boot

Linux_DB2 240879 96794 144086 41% /media/sf_Linux_DB2

tmpfs 184 1 184 1% /run/user/42

tmpfs 184 1 184 1% /run/user/0

*/dev/sr0 56 56 0 100% /run/media/root/VBox_GAs_5.2.20*

[root@localhost home]# df -Pk --block-size=1M | awk '$5 > 40'

Filesystem 1048576-blocks Used Available Capacity Mounted on

/dev/mapper/rhel-root 22510 13135 9375 59% /

Linux_DB2 240879 96794 144086 41% /media/sf_Linux_DB2


The /dev/sr0 56 56 0 100% /run/media/root/VBox_GAs_5.2.20 doesn't come out.










share|improve this question




























    0















    Can someone please help me. I'm trying to get values greater than 40, but when it's at 100 it doesn't get it.



    [root@localhost home]# df -Pk --block-size=1M

    Filesystem 1048576-blocks Used Available Capacity Mounted on

    /dev/mapper/rhel-root 22510 13135 9375 59% /

    devtmpfs 905 0 905 0% /dev

    tmpfs 920 1 920 1% /dev/shm

    tmpfs 920 9 911 1% /run

    tmpfs 920 0 920 0% /sys/fs/cgroup

    /dev/sda1 1014 178 837 18% /boot

    Linux_DB2 240879 96794 144086 41% /media/sf_Linux_DB2

    tmpfs 184 1 184 1% /run/user/42

    tmpfs 184 1 184 1% /run/user/0

    */dev/sr0 56 56 0 100% /run/media/root/VBox_GAs_5.2.20*

    [root@localhost home]# df -Pk --block-size=1M | awk '$5 > 40'

    Filesystem 1048576-blocks Used Available Capacity Mounted on

    /dev/mapper/rhel-root 22510 13135 9375 59% /

    Linux_DB2 240879 96794 144086 41% /media/sf_Linux_DB2


    The /dev/sr0 56 56 0 100% /run/media/root/VBox_GAs_5.2.20 doesn't come out.










    share|improve this question


























      0












      0








      0








      Can someone please help me. I'm trying to get values greater than 40, but when it's at 100 it doesn't get it.



      [root@localhost home]# df -Pk --block-size=1M

      Filesystem 1048576-blocks Used Available Capacity Mounted on

      /dev/mapper/rhel-root 22510 13135 9375 59% /

      devtmpfs 905 0 905 0% /dev

      tmpfs 920 1 920 1% /dev/shm

      tmpfs 920 9 911 1% /run

      tmpfs 920 0 920 0% /sys/fs/cgroup

      /dev/sda1 1014 178 837 18% /boot

      Linux_DB2 240879 96794 144086 41% /media/sf_Linux_DB2

      tmpfs 184 1 184 1% /run/user/42

      tmpfs 184 1 184 1% /run/user/0

      */dev/sr0 56 56 0 100% /run/media/root/VBox_GAs_5.2.20*

      [root@localhost home]# df -Pk --block-size=1M | awk '$5 > 40'

      Filesystem 1048576-blocks Used Available Capacity Mounted on

      /dev/mapper/rhel-root 22510 13135 9375 59% /

      Linux_DB2 240879 96794 144086 41% /media/sf_Linux_DB2


      The /dev/sr0 56 56 0 100% /run/media/root/VBox_GAs_5.2.20 doesn't come out.










      share|improve this question
















      Can someone please help me. I'm trying to get values greater than 40, but when it's at 100 it doesn't get it.



      [root@localhost home]# df -Pk --block-size=1M

      Filesystem 1048576-blocks Used Available Capacity Mounted on

      /dev/mapper/rhel-root 22510 13135 9375 59% /

      devtmpfs 905 0 905 0% /dev

      tmpfs 920 1 920 1% /dev/shm

      tmpfs 920 9 911 1% /run

      tmpfs 920 0 920 0% /sys/fs/cgroup

      /dev/sda1 1014 178 837 18% /boot

      Linux_DB2 240879 96794 144086 41% /media/sf_Linux_DB2

      tmpfs 184 1 184 1% /run/user/42

      tmpfs 184 1 184 1% /run/user/0

      */dev/sr0 56 56 0 100% /run/media/root/VBox_GAs_5.2.20*

      [root@localhost home]# df -Pk --block-size=1M | awk '$5 > 40'

      Filesystem 1048576-blocks Used Available Capacity Mounted on

      /dev/mapper/rhel-root 22510 13135 9375 59% /

      Linux_DB2 240879 96794 144086 41% /media/sf_Linux_DB2


      The /dev/sr0 56 56 0 100% /run/media/root/VBox_GAs_5.2.20 doesn't come out.







      awk grep






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 15 '18 at 1:17









      RavinderSingh13

      30.3k41639




      30.3k41639










      asked Nov 15 '18 at 1:13









      Angela Marielle EstigoyAngela Marielle Estigoy

      142




      142






















          1 Answer
          1






          active

          oldest

          votes


















          2














          Could you please try following once.



          df -hP | awk '$5+0>40'


          Explanation: Since 5th field of disk usage is having string with digits added, so by adding a zero +0 with $5 it tells awk to keep only digits in comparison and it will NOT have strings in it. Then this condition will considered like digits are getting compared, will show the right output then. Here -P option with df command is also crucial since it gives the output of df in a single line and it makes awk command's life easy to get its calculations done.






          share|improve this answer




















          • 1





            OMG! It worked. Can you please explain what the +0 is for?

            – Angela Marielle Estigoy
            Nov 15 '18 at 1:21






          • 1





            Ravinder, a simpler explanation simply would have been "+0 will force awk to treat it as a number rather than a string" :-) But good answer anyway.

            – paxdiablo
            Nov 15 '18 at 1:23












          • @AngelaMarielleEstigoy, you could see this, how could we tell thanks on this great site SO stackoverflow.com/help/someone-answers

            – RavinderSingh13
            Nov 15 '18 at 1:25






          • 1





            Sorry, Ravinder, it was me, but unintentional. It's back now :-)

            – paxdiablo
            Nov 15 '18 at 1:32










          Your Answer






          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "1"
          ;
          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: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          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%2fstackoverflow.com%2fquestions%2f53311077%2fawk-value-greater-than-40%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














          Could you please try following once.



          df -hP | awk '$5+0>40'


          Explanation: Since 5th field of disk usage is having string with digits added, so by adding a zero +0 with $5 it tells awk to keep only digits in comparison and it will NOT have strings in it. Then this condition will considered like digits are getting compared, will show the right output then. Here -P option with df command is also crucial since it gives the output of df in a single line and it makes awk command's life easy to get its calculations done.






          share|improve this answer




















          • 1





            OMG! It worked. Can you please explain what the +0 is for?

            – Angela Marielle Estigoy
            Nov 15 '18 at 1:21






          • 1





            Ravinder, a simpler explanation simply would have been "+0 will force awk to treat it as a number rather than a string" :-) But good answer anyway.

            – paxdiablo
            Nov 15 '18 at 1:23












          • @AngelaMarielleEstigoy, you could see this, how could we tell thanks on this great site SO stackoverflow.com/help/someone-answers

            – RavinderSingh13
            Nov 15 '18 at 1:25






          • 1





            Sorry, Ravinder, it was me, but unintentional. It's back now :-)

            – paxdiablo
            Nov 15 '18 at 1:32















          2














          Could you please try following once.



          df -hP | awk '$5+0>40'


          Explanation: Since 5th field of disk usage is having string with digits added, so by adding a zero +0 with $5 it tells awk to keep only digits in comparison and it will NOT have strings in it. Then this condition will considered like digits are getting compared, will show the right output then. Here -P option with df command is also crucial since it gives the output of df in a single line and it makes awk command's life easy to get its calculations done.






          share|improve this answer




















          • 1





            OMG! It worked. Can you please explain what the +0 is for?

            – Angela Marielle Estigoy
            Nov 15 '18 at 1:21






          • 1





            Ravinder, a simpler explanation simply would have been "+0 will force awk to treat it as a number rather than a string" :-) But good answer anyway.

            – paxdiablo
            Nov 15 '18 at 1:23












          • @AngelaMarielleEstigoy, you could see this, how could we tell thanks on this great site SO stackoverflow.com/help/someone-answers

            – RavinderSingh13
            Nov 15 '18 at 1:25






          • 1





            Sorry, Ravinder, it was me, but unintentional. It's back now :-)

            – paxdiablo
            Nov 15 '18 at 1:32













          2












          2








          2







          Could you please try following once.



          df -hP | awk '$5+0>40'


          Explanation: Since 5th field of disk usage is having string with digits added, so by adding a zero +0 with $5 it tells awk to keep only digits in comparison and it will NOT have strings in it. Then this condition will considered like digits are getting compared, will show the right output then. Here -P option with df command is also crucial since it gives the output of df in a single line and it makes awk command's life easy to get its calculations done.






          share|improve this answer















          Could you please try following once.



          df -hP | awk '$5+0>40'


          Explanation: Since 5th field of disk usage is having string with digits added, so by adding a zero +0 with $5 it tells awk to keep only digits in comparison and it will NOT have strings in it. Then this condition will considered like digits are getting compared, will show the right output then. Here -P option with df command is also crucial since it gives the output of df in a single line and it makes awk command's life easy to get its calculations done.







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Nov 15 '18 at 1:33

























          answered Nov 15 '18 at 1:19









          RavinderSingh13RavinderSingh13

          30.3k41639




          30.3k41639







          • 1





            OMG! It worked. Can you please explain what the +0 is for?

            – Angela Marielle Estigoy
            Nov 15 '18 at 1:21






          • 1





            Ravinder, a simpler explanation simply would have been "+0 will force awk to treat it as a number rather than a string" :-) But good answer anyway.

            – paxdiablo
            Nov 15 '18 at 1:23












          • @AngelaMarielleEstigoy, you could see this, how could we tell thanks on this great site SO stackoverflow.com/help/someone-answers

            – RavinderSingh13
            Nov 15 '18 at 1:25






          • 1





            Sorry, Ravinder, it was me, but unintentional. It's back now :-)

            – paxdiablo
            Nov 15 '18 at 1:32












          • 1





            OMG! It worked. Can you please explain what the +0 is for?

            – Angela Marielle Estigoy
            Nov 15 '18 at 1:21






          • 1





            Ravinder, a simpler explanation simply would have been "+0 will force awk to treat it as a number rather than a string" :-) But good answer anyway.

            – paxdiablo
            Nov 15 '18 at 1:23












          • @AngelaMarielleEstigoy, you could see this, how could we tell thanks on this great site SO stackoverflow.com/help/someone-answers

            – RavinderSingh13
            Nov 15 '18 at 1:25






          • 1





            Sorry, Ravinder, it was me, but unintentional. It's back now :-)

            – paxdiablo
            Nov 15 '18 at 1:32







          1




          1





          OMG! It worked. Can you please explain what the +0 is for?

          – Angela Marielle Estigoy
          Nov 15 '18 at 1:21





          OMG! It worked. Can you please explain what the +0 is for?

          – Angela Marielle Estigoy
          Nov 15 '18 at 1:21




          1




          1





          Ravinder, a simpler explanation simply would have been "+0 will force awk to treat it as a number rather than a string" :-) But good answer anyway.

          – paxdiablo
          Nov 15 '18 at 1:23






          Ravinder, a simpler explanation simply would have been "+0 will force awk to treat it as a number rather than a string" :-) But good answer anyway.

          – paxdiablo
          Nov 15 '18 at 1:23














          @AngelaMarielleEstigoy, you could see this, how could we tell thanks on this great site SO stackoverflow.com/help/someone-answers

          – RavinderSingh13
          Nov 15 '18 at 1:25





          @AngelaMarielleEstigoy, you could see this, how could we tell thanks on this great site SO stackoverflow.com/help/someone-answers

          – RavinderSingh13
          Nov 15 '18 at 1:25




          1




          1





          Sorry, Ravinder, it was me, but unintentional. It's back now :-)

          – paxdiablo
          Nov 15 '18 at 1:32





          Sorry, Ravinder, it was me, but unintentional. It's back now :-)

          – paxdiablo
          Nov 15 '18 at 1:32



















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Stack Overflow!


          • 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%2fstackoverflow.com%2fquestions%2f53311077%2fawk-value-greater-than-40%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

          Kleinkühnau

          Makov (Slowakei)

          Deutsches Schauspielhaus