- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- test on decimal value + awk
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-22-2005 09:16 PM
тАО03-22-2005 09:16 PM
I did a script to get top process with high CPU. I want to do a test with value 1.0 but I do not know how to do correctly the test :
awk '
BEGIN {
printf("PID\tUser\tTime\tCPU\tCommand\t\n")
}
BEGIN {
OFMT="%.6g"
PCPU=1.0
while ("cat /tmp/topfile" | getline )
{if ($12 >= $PCPU)
{OFS="\t"; print $3,$4,$10,$12,$13}
}
}
but I get :
PID User Time CPU Command
20333 appe11t 187:16 3.61 java
16006 root 0:23 0.93 top
25825 appe11t 152:30 0.30 java
21858 orae11t 0:00 0.76 oracleE11T
21558 appe11t 10:21 0.48 java
19392 appp11t 14:32 0.33 java
19390 appp11t 18:41 0.65 java
18558 orae11t 0:00 1.66 oracleE11T
thanks for help
Laurent
Solved! Go to Solution.
- Tags:
- awk
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-22-2005 09:24 PM
тАО03-22-2005 09:24 PM
Re: test on decimal value + awk
have tried replacing >= with -ge
Regards
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-22-2005 09:37 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-22-2005 10:53 PM
тАО03-22-2005 10:53 PM
Re: test on decimal value + awk
what is the difference between $PCPU and PCPU in my condition ?
test on character value and numeric value.
Thanks
Laurent
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-22-2005 11:33 PM
тАО03-22-2005 11:33 PM
Re: test on decimal value + awk
it might help with testing to add before the if statement:
OFS="|";print $12,$PCPU,PCPU
You can then see the $PCPU has null value, whereas PCPU has the correct value.
Also be aware that you are comparing numbers, so 1.0 becomes 1 for the comparisons.
Hope this makes it clearer.
Regards
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-23-2005 12:47 AM
тАО03-23-2005 12:47 AM
Re: test on decimal value + awk
$12 >= $PCPU
Right one should be:
$12 >= PCPU
My own script should be:
awk '
BEGIN {
printf("PID\tUser\tTime\tCPU\tCommand\n")
OFMT="%.6g"
PCPU=1.0
OFS="\t"
}
$12 >= PCPU { print $3,$4,$10,$12,$13 }
' /tmp/topfile