See disk consume info using 'df' command on AIX

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











up vote
1
down vote

favorite












I'm trying to get the fs that have high space consumed. I'm trying to do this using df command with -g flag (gigabyte view) and I can't obtain my expected value.



df -g | sed 's/%//g'| awk '+$5>=75 print' | head -10


With this command below I got an error:



df -g | sed 's/%//g'| awk 'print $5>=75' | head -4


Error Message:



Syntax Error The source line is 1.
The error context is
{print >>> $5>= <<<
awk: 0602-502 The statement cannot be correctly parsed. The source line is 1.


Here is the output of df -g command on AIX:



/tmp>df -g | sed 's/%//g'| awk '$5 >= 75 print ' | head -4
Filesystem GB blocks Free Used Iused Iused Mounted on
/dev/hd4 10.50 10.05 5 16492 1 /
/dev/hd2 25.50 18.15 29 64361 2 /usr
/dev/hd9var 2.50 0.72 72 4521 3 /var


Complete view:



Filesystem GB blocks Free %Used Iused %Iused Mounted on
/dev/hd4 10.50 10.05 5% 16492 1% /
/dev/hd2 25.50 18.15 29% 64357 2% /usr
/dev/hd9var 2.50 1.39 45% 4512 2% /var
/dev/hd3 21.50 20.24 6% 1495 1% /tmp


I tried on AIX 7.1 PowerPC_POWER8. I don't know what I'm doing wrong!










share|improve this question























  • I have no idea if this is required on the AIX flavor of awk or now, but try adding spaces? Also, your two awk statements are different. $5 >= 75 print will print the input line if the fifth field is greater than or equal to 75; print $5 >= 75 will print a zero or one based on the truthiness of the inequality.
    – DopeGhoti
    Aug 23 '17 at 18:44










  • Yes, I know it. I want exactly the result of $5 >= 75 print but I cant see this result. I tried adding spaces and It does not work.
    – vicdeveloper
    Aug 23 '17 at 18:50










  • You should probably add an example of the output of df -g to the text in the question. There's not many here with an AIX system at hand. Also, never say "it does not work" without also saying exactly in what way it doesn't work.
    – Kusalananda
    Aug 23 '17 at 19:02











  • Oks, I will edit main post.
    – vicdeveloper
    Aug 23 '17 at 19:03















up vote
1
down vote

favorite












I'm trying to get the fs that have high space consumed. I'm trying to do this using df command with -g flag (gigabyte view) and I can't obtain my expected value.



df -g | sed 's/%//g'| awk '+$5>=75 print' | head -10


With this command below I got an error:



df -g | sed 's/%//g'| awk 'print $5>=75' | head -4


Error Message:



Syntax Error The source line is 1.
The error context is
{print >>> $5>= <<<
awk: 0602-502 The statement cannot be correctly parsed. The source line is 1.


Here is the output of df -g command on AIX:



/tmp>df -g | sed 's/%//g'| awk '$5 >= 75 print ' | head -4
Filesystem GB blocks Free Used Iused Iused Mounted on
/dev/hd4 10.50 10.05 5 16492 1 /
/dev/hd2 25.50 18.15 29 64361 2 /usr
/dev/hd9var 2.50 0.72 72 4521 3 /var


Complete view:



Filesystem GB blocks Free %Used Iused %Iused Mounted on
/dev/hd4 10.50 10.05 5% 16492 1% /
/dev/hd2 25.50 18.15 29% 64357 2% /usr
/dev/hd9var 2.50 1.39 45% 4512 2% /var
/dev/hd3 21.50 20.24 6% 1495 1% /tmp


I tried on AIX 7.1 PowerPC_POWER8. I don't know what I'm doing wrong!










share|improve this question























  • I have no idea if this is required on the AIX flavor of awk or now, but try adding spaces? Also, your two awk statements are different. $5 >= 75 print will print the input line if the fifth field is greater than or equal to 75; print $5 >= 75 will print a zero or one based on the truthiness of the inequality.
    – DopeGhoti
    Aug 23 '17 at 18:44










  • Yes, I know it. I want exactly the result of $5 >= 75 print but I cant see this result. I tried adding spaces and It does not work.
    – vicdeveloper
    Aug 23 '17 at 18:50










  • You should probably add an example of the output of df -g to the text in the question. There's not many here with an AIX system at hand. Also, never say "it does not work" without also saying exactly in what way it doesn't work.
    – Kusalananda
    Aug 23 '17 at 19:02











  • Oks, I will edit main post.
    – vicdeveloper
    Aug 23 '17 at 19:03













up vote
1
down vote

favorite









up vote
1
down vote

favorite











I'm trying to get the fs that have high space consumed. I'm trying to do this using df command with -g flag (gigabyte view) and I can't obtain my expected value.



df -g | sed 's/%//g'| awk '+$5>=75 print' | head -10


With this command below I got an error:



df -g | sed 's/%//g'| awk 'print $5>=75' | head -4


Error Message:



Syntax Error The source line is 1.
The error context is
{print >>> $5>= <<<
awk: 0602-502 The statement cannot be correctly parsed. The source line is 1.


Here is the output of df -g command on AIX:



/tmp>df -g | sed 's/%//g'| awk '$5 >= 75 print ' | head -4
Filesystem GB blocks Free Used Iused Iused Mounted on
/dev/hd4 10.50 10.05 5 16492 1 /
/dev/hd2 25.50 18.15 29 64361 2 /usr
/dev/hd9var 2.50 0.72 72 4521 3 /var


Complete view:



Filesystem GB blocks Free %Used Iused %Iused Mounted on
/dev/hd4 10.50 10.05 5% 16492 1% /
/dev/hd2 25.50 18.15 29% 64357 2% /usr
/dev/hd9var 2.50 1.39 45% 4512 2% /var
/dev/hd3 21.50 20.24 6% 1495 1% /tmp


I tried on AIX 7.1 PowerPC_POWER8. I don't know what I'm doing wrong!










share|improve this question















I'm trying to get the fs that have high space consumed. I'm trying to do this using df command with -g flag (gigabyte view) and I can't obtain my expected value.



df -g | sed 's/%//g'| awk '+$5>=75 print' | head -10


With this command below I got an error:



df -g | sed 's/%//g'| awk 'print $5>=75' | head -4


Error Message:



Syntax Error The source line is 1.
The error context is
{print >>> $5>= <<<
awk: 0602-502 The statement cannot be correctly parsed. The source line is 1.


Here is the output of df -g command on AIX:



/tmp>df -g | sed 's/%//g'| awk '$5 >= 75 print ' | head -4
Filesystem GB blocks Free Used Iused Iused Mounted on
/dev/hd4 10.50 10.05 5 16492 1 /
/dev/hd2 25.50 18.15 29 64361 2 /usr
/dev/hd9var 2.50 0.72 72 4521 3 /var


Complete view:



Filesystem GB blocks Free %Used Iused %Iused Mounted on
/dev/hd4 10.50 10.05 5% 16492 1% /
/dev/hd2 25.50 18.15 29% 64357 2% /usr
/dev/hd9var 2.50 1.39 45% 4512 2% /var
/dev/hd3 21.50 20.24 6% 1495 1% /tmp


I tried on AIX 7.1 PowerPC_POWER8. I don't know what I'm doing wrong!







awk disk-usage aix






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Aug 23 '17 at 20:14









Jeff Schaller

32.7k849110




32.7k849110










asked Aug 23 '17 at 18:27









vicdeveloper

68129




68129











  • I have no idea if this is required on the AIX flavor of awk or now, but try adding spaces? Also, your two awk statements are different. $5 >= 75 print will print the input line if the fifth field is greater than or equal to 75; print $5 >= 75 will print a zero or one based on the truthiness of the inequality.
    – DopeGhoti
    Aug 23 '17 at 18:44










  • Yes, I know it. I want exactly the result of $5 >= 75 print but I cant see this result. I tried adding spaces and It does not work.
    – vicdeveloper
    Aug 23 '17 at 18:50










  • You should probably add an example of the output of df -g to the text in the question. There's not many here with an AIX system at hand. Also, never say "it does not work" without also saying exactly in what way it doesn't work.
    – Kusalananda
    Aug 23 '17 at 19:02











  • Oks, I will edit main post.
    – vicdeveloper
    Aug 23 '17 at 19:03

















  • I have no idea if this is required on the AIX flavor of awk or now, but try adding spaces? Also, your two awk statements are different. $5 >= 75 print will print the input line if the fifth field is greater than or equal to 75; print $5 >= 75 will print a zero or one based on the truthiness of the inequality.
    – DopeGhoti
    Aug 23 '17 at 18:44










  • Yes, I know it. I want exactly the result of $5 >= 75 print but I cant see this result. I tried adding spaces and It does not work.
    – vicdeveloper
    Aug 23 '17 at 18:50










  • You should probably add an example of the output of df -g to the text in the question. There's not many here with an AIX system at hand. Also, never say "it does not work" without also saying exactly in what way it doesn't work.
    – Kusalananda
    Aug 23 '17 at 19:02











  • Oks, I will edit main post.
    – vicdeveloper
    Aug 23 '17 at 19:03
















I have no idea if this is required on the AIX flavor of awk or now, but try adding spaces? Also, your two awk statements are different. $5 >= 75 print will print the input line if the fifth field is greater than or equal to 75; print $5 >= 75 will print a zero or one based on the truthiness of the inequality.
– DopeGhoti
Aug 23 '17 at 18:44




I have no idea if this is required on the AIX flavor of awk or now, but try adding spaces? Also, your two awk statements are different. $5 >= 75 print will print the input line if the fifth field is greater than or equal to 75; print $5 >= 75 will print a zero or one based on the truthiness of the inequality.
– DopeGhoti
Aug 23 '17 at 18:44












Yes, I know it. I want exactly the result of $5 >= 75 print but I cant see this result. I tried adding spaces and It does not work.
– vicdeveloper
Aug 23 '17 at 18:50




Yes, I know it. I want exactly the result of $5 >= 75 print but I cant see this result. I tried adding spaces and It does not work.
– vicdeveloper
Aug 23 '17 at 18:50












You should probably add an example of the output of df -g to the text in the question. There's not many here with an AIX system at hand. Also, never say "it does not work" without also saying exactly in what way it doesn't work.
– Kusalananda
Aug 23 '17 at 19:02





You should probably add an example of the output of df -g to the text in the question. There's not many here with an AIX system at hand. Also, never say "it does not work" without also saying exactly in what way it doesn't work.
– Kusalananda
Aug 23 '17 at 19:02













Oks, I will edit main post.
– vicdeveloper
Aug 23 '17 at 19:03





Oks, I will edit main post.
– vicdeveloper
Aug 23 '17 at 19:03











3 Answers
3






active

oldest

votes

















up vote
1
down vote



accepted










Concentrating on the awk code:



awk 'print $5>=75'


This should probably be



awk '$5 >= 75 print '


which will output the current input record if its fifth field is numerically greater than or equal to 75.



Judging from the output that you get, you probably want to check $4 rather than $5 though since I presume it's the fourth field that contains the percentage:



df -g | tr -d '%' | awk '$4 >= 75 print ' | head -4



Looking at the error message:
Using awk on OpenBSD (which seems to complain in exactly the same way as your AIX awk), the original code has a syntax error in that it's not possible to print $5 >= 75 (unless put inside parentheses in which case it will evaluate to 0 (false) or 1 (true)). mawk behaves the same.



GNU awk accepts the syntax in the original code, but it's obviously still not what you want.






share|improve this answer






















  • BSD awk (as provided by McOS) is also perfectly happy with this syntax, but throwing it into a parenthetical is probably a good idea anyhow, to make it clear that you want to be doing what you're doing in five years when future-you is reading the awk script.
    – DopeGhoti
    Aug 23 '17 at 18:56






  • 1




    @Kusulananda: I edited the main post and added the df -g command output.
    – vicdeveloper
    Aug 23 '17 at 19:12










  • @vicdeveloper Updated. Since you didn't show the df -g output I'm only guessing that you actually want column 4 rather than 5. It's hard to tell with the % removed.
    – Kusalananda
    Aug 23 '17 at 19:20










  • See the main post. I added the complete view.
    – vicdeveloper
    Aug 23 '17 at 19:22







  • 1




    Hello, I find my expected result using this command: **df -g | tr -d '%' | awk '$4 >= 70 print ' | awk 'print $4, $7'| sort -n | uniq** Many thanks for all of your responses.
    – vicdeveloper
    Aug 23 '17 at 19:38


















up vote
2
down vote













Instead of using tr and awk twice, just use awk once:



df -g | awk ' sub("%", "", $4); if ($4 >= 75) print $4, $7 ' | sort -n


This replaces the percent signs in field 4 with the empty string (stripping them off); if the remaining value is at least 75, print fields 4 and 7, then pipe them to sort.



An improvement, based on remembering one of Stéphane's answers:



df -g | awk '$4+0 >= 75 print $4, $7 ' | sort -n


The "+0" addition forces a numerical comparison instead of a strictly string-based comparison.



If you want to keep the header, change the criteria to:



df -g | awk 'NR < 2 || $4+0 >= 75 print $4, $7 ' | sort -n





share|improve this answer





























    up vote
    0
    down vote













    This is the error ... 'Filesystem GB blocks Free Used Iused Iused Mounted on'



    The solution is:



    # df -g | grep Filesystem | sed 's/%//g'| awk 'print $5>=75' | head -4






    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: 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%2f387954%2fsee-disk-consume-info-using-df-command-on-aix%23new-answer', 'question_page');

      );

      Post as a guest






























      3 Answers
      3






      active

      oldest

      votes








      3 Answers
      3






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes








      up vote
      1
      down vote



      accepted










      Concentrating on the awk code:



      awk 'print $5>=75'


      This should probably be



      awk '$5 >= 75 print '


      which will output the current input record if its fifth field is numerically greater than or equal to 75.



      Judging from the output that you get, you probably want to check $4 rather than $5 though since I presume it's the fourth field that contains the percentage:



      df -g | tr -d '%' | awk '$4 >= 75 print ' | head -4



      Looking at the error message:
      Using awk on OpenBSD (which seems to complain in exactly the same way as your AIX awk), the original code has a syntax error in that it's not possible to print $5 >= 75 (unless put inside parentheses in which case it will evaluate to 0 (false) or 1 (true)). mawk behaves the same.



      GNU awk accepts the syntax in the original code, but it's obviously still not what you want.






      share|improve this answer






















      • BSD awk (as provided by McOS) is also perfectly happy with this syntax, but throwing it into a parenthetical is probably a good idea anyhow, to make it clear that you want to be doing what you're doing in five years when future-you is reading the awk script.
        – DopeGhoti
        Aug 23 '17 at 18:56






      • 1




        @Kusulananda: I edited the main post and added the df -g command output.
        – vicdeveloper
        Aug 23 '17 at 19:12










      • @vicdeveloper Updated. Since you didn't show the df -g output I'm only guessing that you actually want column 4 rather than 5. It's hard to tell with the % removed.
        – Kusalananda
        Aug 23 '17 at 19:20










      • See the main post. I added the complete view.
        – vicdeveloper
        Aug 23 '17 at 19:22







      • 1




        Hello, I find my expected result using this command: **df -g | tr -d '%' | awk '$4 >= 70 print ' | awk 'print $4, $7'| sort -n | uniq** Many thanks for all of your responses.
        – vicdeveloper
        Aug 23 '17 at 19:38















      up vote
      1
      down vote



      accepted










      Concentrating on the awk code:



      awk 'print $5>=75'


      This should probably be



      awk '$5 >= 75 print '


      which will output the current input record if its fifth field is numerically greater than or equal to 75.



      Judging from the output that you get, you probably want to check $4 rather than $5 though since I presume it's the fourth field that contains the percentage:



      df -g | tr -d '%' | awk '$4 >= 75 print ' | head -4



      Looking at the error message:
      Using awk on OpenBSD (which seems to complain in exactly the same way as your AIX awk), the original code has a syntax error in that it's not possible to print $5 >= 75 (unless put inside parentheses in which case it will evaluate to 0 (false) or 1 (true)). mawk behaves the same.



      GNU awk accepts the syntax in the original code, but it's obviously still not what you want.






      share|improve this answer






















      • BSD awk (as provided by McOS) is also perfectly happy with this syntax, but throwing it into a parenthetical is probably a good idea anyhow, to make it clear that you want to be doing what you're doing in five years when future-you is reading the awk script.
        – DopeGhoti
        Aug 23 '17 at 18:56






      • 1




        @Kusulananda: I edited the main post and added the df -g command output.
        – vicdeveloper
        Aug 23 '17 at 19:12










      • @vicdeveloper Updated. Since you didn't show the df -g output I'm only guessing that you actually want column 4 rather than 5. It's hard to tell with the % removed.
        – Kusalananda
        Aug 23 '17 at 19:20










      • See the main post. I added the complete view.
        – vicdeveloper
        Aug 23 '17 at 19:22







      • 1




        Hello, I find my expected result using this command: **df -g | tr -d '%' | awk '$4 >= 70 print ' | awk 'print $4, $7'| sort -n | uniq** Many thanks for all of your responses.
        – vicdeveloper
        Aug 23 '17 at 19:38













      up vote
      1
      down vote



      accepted







      up vote
      1
      down vote



      accepted






      Concentrating on the awk code:



      awk 'print $5>=75'


      This should probably be



      awk '$5 >= 75 print '


      which will output the current input record if its fifth field is numerically greater than or equal to 75.



      Judging from the output that you get, you probably want to check $4 rather than $5 though since I presume it's the fourth field that contains the percentage:



      df -g | tr -d '%' | awk '$4 >= 75 print ' | head -4



      Looking at the error message:
      Using awk on OpenBSD (which seems to complain in exactly the same way as your AIX awk), the original code has a syntax error in that it's not possible to print $5 >= 75 (unless put inside parentheses in which case it will evaluate to 0 (false) or 1 (true)). mawk behaves the same.



      GNU awk accepts the syntax in the original code, but it's obviously still not what you want.






      share|improve this answer














      Concentrating on the awk code:



      awk 'print $5>=75'


      This should probably be



      awk '$5 >= 75 print '


      which will output the current input record if its fifth field is numerically greater than or equal to 75.



      Judging from the output that you get, you probably want to check $4 rather than $5 though since I presume it's the fourth field that contains the percentage:



      df -g | tr -d '%' | awk '$4 >= 75 print ' | head -4



      Looking at the error message:
      Using awk on OpenBSD (which seems to complain in exactly the same way as your AIX awk), the original code has a syntax error in that it's not possible to print $5 >= 75 (unless put inside parentheses in which case it will evaluate to 0 (false) or 1 (true)). mawk behaves the same.



      GNU awk accepts the syntax in the original code, but it's obviously still not what you want.







      share|improve this answer














      share|improve this answer



      share|improve this answer








      edited Aug 23 '17 at 19:12

























      answered Aug 23 '17 at 18:50









      Kusalananda

      107k14209329




      107k14209329











      • BSD awk (as provided by McOS) is also perfectly happy with this syntax, but throwing it into a parenthetical is probably a good idea anyhow, to make it clear that you want to be doing what you're doing in five years when future-you is reading the awk script.
        – DopeGhoti
        Aug 23 '17 at 18:56






      • 1




        @Kusulananda: I edited the main post and added the df -g command output.
        – vicdeveloper
        Aug 23 '17 at 19:12










      • @vicdeveloper Updated. Since you didn't show the df -g output I'm only guessing that you actually want column 4 rather than 5. It's hard to tell with the % removed.
        – Kusalananda
        Aug 23 '17 at 19:20










      • See the main post. I added the complete view.
        – vicdeveloper
        Aug 23 '17 at 19:22







      • 1




        Hello, I find my expected result using this command: **df -g | tr -d '%' | awk '$4 >= 70 print ' | awk 'print $4, $7'| sort -n | uniq** Many thanks for all of your responses.
        – vicdeveloper
        Aug 23 '17 at 19:38

















      • BSD awk (as provided by McOS) is also perfectly happy with this syntax, but throwing it into a parenthetical is probably a good idea anyhow, to make it clear that you want to be doing what you're doing in five years when future-you is reading the awk script.
        – DopeGhoti
        Aug 23 '17 at 18:56






      • 1




        @Kusulananda: I edited the main post and added the df -g command output.
        – vicdeveloper
        Aug 23 '17 at 19:12










      • @vicdeveloper Updated. Since you didn't show the df -g output I'm only guessing that you actually want column 4 rather than 5. It's hard to tell with the % removed.
        – Kusalananda
        Aug 23 '17 at 19:20










      • See the main post. I added the complete view.
        – vicdeveloper
        Aug 23 '17 at 19:22







      • 1




        Hello, I find my expected result using this command: **df -g | tr -d '%' | awk '$4 >= 70 print ' | awk 'print $4, $7'| sort -n | uniq** Many thanks for all of your responses.
        – vicdeveloper
        Aug 23 '17 at 19:38
















      BSD awk (as provided by McOS) is also perfectly happy with this syntax, but throwing it into a parenthetical is probably a good idea anyhow, to make it clear that you want to be doing what you're doing in five years when future-you is reading the awk script.
      – DopeGhoti
      Aug 23 '17 at 18:56




      BSD awk (as provided by McOS) is also perfectly happy with this syntax, but throwing it into a parenthetical is probably a good idea anyhow, to make it clear that you want to be doing what you're doing in five years when future-you is reading the awk script.
      – DopeGhoti
      Aug 23 '17 at 18:56




      1




      1




      @Kusulananda: I edited the main post and added the df -g command output.
      – vicdeveloper
      Aug 23 '17 at 19:12




      @Kusulananda: I edited the main post and added the df -g command output.
      – vicdeveloper
      Aug 23 '17 at 19:12












      @vicdeveloper Updated. Since you didn't show the df -g output I'm only guessing that you actually want column 4 rather than 5. It's hard to tell with the % removed.
      – Kusalananda
      Aug 23 '17 at 19:20




      @vicdeveloper Updated. Since you didn't show the df -g output I'm only guessing that you actually want column 4 rather than 5. It's hard to tell with the % removed.
      – Kusalananda
      Aug 23 '17 at 19:20












      See the main post. I added the complete view.
      – vicdeveloper
      Aug 23 '17 at 19:22





      See the main post. I added the complete view.
      – vicdeveloper
      Aug 23 '17 at 19:22





      1




      1




      Hello, I find my expected result using this command: **df -g | tr -d '%' | awk '$4 >= 70 print ' | awk 'print $4, $7'| sort -n | uniq** Many thanks for all of your responses.
      – vicdeveloper
      Aug 23 '17 at 19:38





      Hello, I find my expected result using this command: **df -g | tr -d '%' | awk '$4 >= 70 print ' | awk 'print $4, $7'| sort -n | uniq** Many thanks for all of your responses.
      – vicdeveloper
      Aug 23 '17 at 19:38













      up vote
      2
      down vote













      Instead of using tr and awk twice, just use awk once:



      df -g | awk ' sub("%", "", $4); if ($4 >= 75) print $4, $7 ' | sort -n


      This replaces the percent signs in field 4 with the empty string (stripping them off); if the remaining value is at least 75, print fields 4 and 7, then pipe them to sort.



      An improvement, based on remembering one of Stéphane's answers:



      df -g | awk '$4+0 >= 75 print $4, $7 ' | sort -n


      The "+0" addition forces a numerical comparison instead of a strictly string-based comparison.



      If you want to keep the header, change the criteria to:



      df -g | awk 'NR < 2 || $4+0 >= 75 print $4, $7 ' | sort -n





      share|improve this answer


























        up vote
        2
        down vote













        Instead of using tr and awk twice, just use awk once:



        df -g | awk ' sub("%", "", $4); if ($4 >= 75) print $4, $7 ' | sort -n


        This replaces the percent signs in field 4 with the empty string (stripping them off); if the remaining value is at least 75, print fields 4 and 7, then pipe them to sort.



        An improvement, based on remembering one of Stéphane's answers:



        df -g | awk '$4+0 >= 75 print $4, $7 ' | sort -n


        The "+0" addition forces a numerical comparison instead of a strictly string-based comparison.



        If you want to keep the header, change the criteria to:



        df -g | awk 'NR < 2 || $4+0 >= 75 print $4, $7 ' | sort -n





        share|improve this answer
























          up vote
          2
          down vote










          up vote
          2
          down vote









          Instead of using tr and awk twice, just use awk once:



          df -g | awk ' sub("%", "", $4); if ($4 >= 75) print $4, $7 ' | sort -n


          This replaces the percent signs in field 4 with the empty string (stripping them off); if the remaining value is at least 75, print fields 4 and 7, then pipe them to sort.



          An improvement, based on remembering one of Stéphane's answers:



          df -g | awk '$4+0 >= 75 print $4, $7 ' | sort -n


          The "+0" addition forces a numerical comparison instead of a strictly string-based comparison.



          If you want to keep the header, change the criteria to:



          df -g | awk 'NR < 2 || $4+0 >= 75 print $4, $7 ' | sort -n





          share|improve this answer














          Instead of using tr and awk twice, just use awk once:



          df -g | awk ' sub("%", "", $4); if ($4 >= 75) print $4, $7 ' | sort -n


          This replaces the percent signs in field 4 with the empty string (stripping them off); if the remaining value is at least 75, print fields 4 and 7, then pipe them to sort.



          An improvement, based on remembering one of Stéphane's answers:



          df -g | awk '$4+0 >= 75 print $4, $7 ' | sort -n


          The "+0" addition forces a numerical comparison instead of a strictly string-based comparison.



          If you want to keep the header, change the criteria to:



          df -g | awk 'NR < 2 || $4+0 >= 75 print $4, $7 ' | sort -n






          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Aug 23 '17 at 20:22

























          answered Aug 23 '17 at 19:51









          Jeff Schaller

          32.7k849110




          32.7k849110




















              up vote
              0
              down vote













              This is the error ... 'Filesystem GB blocks Free Used Iused Iused Mounted on'



              The solution is:



              # df -g | grep Filesystem | sed 's/%//g'| awk 'print $5>=75' | head -4






              share|improve this answer


























                up vote
                0
                down vote













                This is the error ... 'Filesystem GB blocks Free Used Iused Iused Mounted on'



                The solution is:



                # df -g | grep Filesystem | sed 's/%//g'| awk 'print $5>=75' | head -4






                share|improve this answer
























                  up vote
                  0
                  down vote










                  up vote
                  0
                  down vote









                  This is the error ... 'Filesystem GB blocks Free Used Iused Iused Mounted on'



                  The solution is:



                  # df -g | grep Filesystem | sed 's/%//g'| awk 'print $5>=75' | head -4






                  share|improve this answer














                  This is the error ... 'Filesystem GB blocks Free Used Iused Iused Mounted on'



                  The solution is:



                  # df -g | grep Filesystem | sed 's/%//g'| awk 'print $5>=75' | head -4







                  share|improve this answer














                  share|improve this answer



                  share|improve this answer








                  edited Aug 24 at 3:36









                  fpmurphy1

                  2,250915




                  2,250915










                  answered Aug 23 at 22:53









                  Henrique Nunes

                  1




                  1



























                       

                      draft saved


                      draft discarded















































                       


                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function ()
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f387954%2fsee-disk-consume-info-using-df-command-on-aix%23new-answer', 'question_page');

                      );

                      Post as a guest













































































                      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