HPE GreenLake Administration
- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Awk Script Help
Operating System - HP-UX
1836626
Members
1703
Online
110102
Solutions
Forums
Categories
Company
Local Language
back
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
back
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
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Go to solution
Topic Options
- 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
01-20-2004 05:30 AM
01-20-2004 05:30 AM
Hi Masters,
Please help me to write a shell script to get the desired output as described below:
Input file content:
call count cpu elapsed disk query current rows
------- ------ -------- ---------- ---------- ---------- ---------- ----------
Parse D 0.01 0.02 0 0 0 0
Execute E 0.00 0.00 0 0 0 0
Fetch J 1.31 1.58 2169 6951 36 I
------- ------ -------- ---------- ---------- ---------- ---------- ----------
total 45 1.32 1.60 K F G H
Desired Output:
I want to display following ratios using "AWK"
i. F+G
F+G
2. ---
H
3. D/E
4. I/J
5. K
----
F+G
Thanks in advance.
Points will be awarded.
Please help me to write a shell script to get the desired output as described below:
Input file content:
call count cpu elapsed disk query current rows
------- ------ -------- ---------- ---------- ---------- ---------- ----------
Parse D 0.01 0.02 0 0 0 0
Execute E 0.00 0.00 0 0 0 0
Fetch J 1.31 1.58 2169 6951 36 I
------- ------ -------- ---------- ---------- ---------- ---------- ----------
total 45 1.32 1.60 K F G H
Desired Output:
I want to display following ratios using "AWK"
i. F+G
F+G
2. ---
H
3. D/E
4. I/J
5. K
----
F+G
Thanks in advance.
Points will be awarded.
Solved! Go to Solution.
3 REPLIES 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-20-2004 08:47 AM
01-20-2004 08:47 AM
Re: Awk Script Help
Start simple and then you can build on this:
get F+G
awk "/total/ { print $6+$7 }" inputFile
Get H
awk "/total/ { print $8 }" inputfile
and you can combine them into a file (x1 say):
/total/ { print $6+$7 }
/total/ { print $8 }
and then use it
awk -f x1 inputFile
where inputFile is the file that contains your
original info.
Play with that and you can learn awk on the way.
HTH ...Laurie :{)
get F+G
awk "/total/ { print $6+$7 }" inputFile
Get H
awk "/total/ { print $8 }" inputfile
and you can combine them into a file (x1 say):
/total/ { print $6+$7 }
/total/ { print $8 }
and then use it
awk -f x1 inputFile
where inputFile is the file that contains your
original info.
Play with that and you can learn awk on the way.
HTH ...Laurie :{)
If you're not using OverTime, you're doing overtime!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-20-2004 09:20 AM
01-20-2004 09:20 AM
Re: Awk Script Help
Sorry, but the desired output formatting is unclear to me. Still, I'm sure you can get going using the following:
# cat x.awk
/^Par/{ d = $2}
/^Exe/{ e = $2}
/^Fet/{ j = $2}
/^tot/{ k = $5; f = $6; g = $7; h = $8;
print d,e,j,k,f,g,h;
}
END { printf "(could be part of total processing) D/E = %5.2f%%\n",100*d/e }
# cat x
call count cpu elapsed disk query current rows
------- ------ -------- ---------- ---------- ---------- ---------- ----------
Parse 1 0.01 0.02 0 0 0 0
Execute 3 0.00 0.00 0 0 0 0
Fetch J 1.31 1.58 2169 6951 36 I
------- ------ -------- ---------- ---------- ---------- ---------- ----------
total 45 1.32 1.60 K F G H
# awk -f x.awk < x
1 3 J K F G H
(could be part of total processing) D/E = 33.33%
Enjoy...
Hein.
# cat x.awk
/^Par/{ d = $2}
/^Exe/{ e = $2}
/^Fet/{ j = $2}
/^tot/{ k = $5; f = $6; g = $7; h = $8;
print d,e,j,k,f,g,h;
}
END { printf "(could be part of total processing) D/E = %5.2f%%\n",100*d/e }
# cat x
call count cpu elapsed disk query current rows
------- ------ -------- ---------- ---------- ---------- ---------- ----------
Parse 1 0.01 0.02 0 0 0 0
Execute 3 0.00 0.00 0 0 0 0
Fetch J 1.31 1.58 2169 6951 36 I
------- ------ -------- ---------- ---------- ---------- ---------- ----------
total 45 1.32 1.60 K F G H
# awk -f x.awk < x
1 3 J K F G H
(could be part of total processing) D/E = 33.33%
Enjoy...
Hein.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-20-2004 09:21 AM
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
Company
Events and news
Customer resources
© Copyright 2025 Hewlett Packard Enterprise Development LP