![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Format output using awk in script. | bperl | Shell Programming and Scripting | 8 | 01-14-2008 01:09 AM |
| [need help] output format from awk | bucci | Shell Programming and Scripting | 6 | 02-09-2007 04:41 AM |
| format output | Tornado | Shell Programming and Scripting | 7 | 11-19-2006 06:17 AM |
| ls output format | tonyt | UNIX for Dummies Questions & Answers | 6 | 11-23-2001 11:31 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
Output in a particular format using AWK
Hi All,
I am trying to check if if column 5 is greater than 90. If greater it will print the term in column 6, else if all are within limit, then it will output "Size is within limit". I can't seem to do that with the below code. The output should only be 1 statement of "Size is within the limit" since all column 5 numbers are less 90. Can somebody advise me what's wrong with my code ? Input: /aaa 0 0 0 0 /zzz /aaa 240553 145567 70931 68 / /aaa 1170399 800131 311749 72 /qqq zz 0 0 0 0 /rrr /xxx 288445 139404 120197 54 /ttt /xxx 6048174 1946727 4040966 33 /ggg /xxx 336337 225215 77489 75 /uuu /xxx 8813861 2025333 6700390 24 /ooo zzz 496704 35864 460840 8 /ppp aaa 3073262 1757331 1254466 59 /hhh aaa 140074829 106235104 32438977 77 /lll ddd 6048174 1946727 4040966 33 /vvvv ddd 140074829 106235104 32438977 77 /nnn Code:
BEGIN {}
{
if ($5 > 90) Dir = $6; printf("%5s is over 90%.Pls take note!\n",Dir);
if ($5 < 90) printf("Size is within Limit.\n");
}
END{}
$ nawk -f awk_proto sys_info2.txt is over 90%.PPls take note! Size is within Limit. is over 90%.PPls take note! Size is within Limit. is over 90%.PPls take note! Size is within Limit. is over 90%.PPls take note! Size is within Limit. is over 90%.PPls take note! Size is within Limit. is over 90%.PPls take note! Size is within Limit. is over 90%.PPls take note! Size is within Limit. is over 90%.PPls take note! Size is within Limit. is over 90%.PPls take note! Size is within Limit. is over 90%.PPls take note! Size is within Limit. is over 90%.PPls take note! Size is within Limit. is over 90%.PPls take note! Size is within Limit. is over 90%.PPls take note! Size is within Limit. |
|
||||
|
Hi anbu,
My output now is below: $ nawk -f awk_proto sys_info2.txt Size is within limit. Size is within limit. Size is within limit. Size is within limit. Size is within limit. Size is within limit. Size is within limit. Size is within limit. Size is within limit. Size is within limit. Size is within limit. Size is within limit. Size is within limit. Can i output only 1 of the above statement when all are within the limits? Once 1 of the value is not within the limits, this statement would not be displayed. |
|
||||
|
Hi Anbu,
It works fine with that code of yours. Thanks alot! |
| Sponsored Links | ||
|
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|