- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: script functionality
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
Forums
Discussions
Discussions
Discussions
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
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-06-2003 06:16 AM
03-06-2003 06:16 AM
script functionality
I have a problem whereby I require to extract values from a file. The problem is some lines contain multiple values and I need to retrieve just the first or second value on occasions.
e.g.
Buffer Nowait %: 100.00 Redo NoWait %: 70.00
Buffer Hit %: 96.68 In-memory Sort %: 99.83
Library Hit %: 99.89 Soft Parse %: 99.64
Execute to Parse %: 57.07 Latch Hit %: 99.99
From this I need to retrieve each value in turn, I am using grep to isolate the row but now I need to extract only the relevant value, e.g. when I need the IN_MEMORY SORT I only want 99.83 and not the entire line. Similarly when I want BUFFER HIT I want 99.68 and nothing else from the line.
Any ideas?
Thanks in advance
Dave
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-06-2003 06:22 AM
03-06-2003 06:22 AM
Re: script functionality
awk -F': ' '{print $2,$3}' file | awk '{print $1,$NF}'
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-06-2003 06:30 AM
03-06-2003 06:30 AM
Re: script functionality
cat myfile |awk -F% '{print $2}' |awk '{print $2}'
To get the second value:
cat myfile |awk -F% '{print $2}' |awk '{print $2}'
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-06-2003 06:36 AM
03-06-2003 06:36 AM
Re: script functionality
cat file|while read line
do
treatment of line
done
Then you have the lines 1 by 1 in varaible line.
ex
cat file|while read line
do
echo $line|cut -f3 -d":"
done
gives only the last field.
What do you need for format
Steve Steel
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-06-2003 06:44 AM
03-06-2003 06:44 AM
Re: script functionality
Buffer Hit %: 96.68 In-memory Sort %: 99.83
Library Hit %: 99.89 Soft Parse %: 99.64
Execute to Parse %: 57.07 Latch Hit %: 99.99
a5:/tmp 111 > perl -nle'BEGIN{$pat=shift}/\s*([a-z_. -]*?$pat[\w%:. -]*?[\d.]+)/i&&print$1' memory xx
In-memory Sort %: 99.83
a5:/tmp 112 > perl -nle'BEGIN{$pat=shift}/\s*([a-z_. -]*?$pat[\w%:. -]*?[\d.]+)/i&&print$1' parse xx
Soft Parse %: 99.64
Execute to Parse %: 57.07
a5:/tmp 113 >
you can allways turn this into a script :)
Enjoy, have FUN! H.Merijn
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-06-2003 06:45 AM
03-06-2003 06:45 AM
Re: script functionality
awk is fun but anyway here is another silly one
cat file|while read line
do
f1=$(echo $line|cut -f1 -d":")
f2=$(echo $line|cut -f2 -d":")
f2a=$(echo $f2|cut -f1 -d" ")
f2b=$(echo $f2|cut -f2 -d" ")
f3=$(echo $line|cut -f3 -d":")
echo $f2a $f1
echo $f3 $f2b
done|sort -n
output is
57.07 Execute to Parse %
70.00 Redo
96.68 Buffer Hit %
99.64 Soft
99.83 In-memory
99.89 Library Hit %
99.99 Latch
100.00 Buffer Nowait %
It is endless
Steve steel
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-06-2003 06:51 AM
03-06-2003 06:51 AM
Re: script functionality
a5:/tmp 117 > cat xx
Buffer Nowait %: 100.00 Redo NoWait %: 70.00
Buffer Hit %: 96.68 In-memory Sort %: 99.83
Library Hit %: 99.89 Soft Parse %: 99.64
Execute to Parse %: 57.07 Latch Hit %: 99.99
a5:/tmp 118 > cat xx.pl
#!/usr/bin/perl -l
$pat = shift;
while (<>) {
/\s*([a-z_. -]*?$pat[\w%:. -]*?[\d.]+)/i && print $1;
}
a5:/tmp 119 > xx.pl memory xx
In-memory Sort %: 99.83
a5:/tmp 120 > xx.pl parse xx
Soft Parse %: 99.64
Execute to Parse %: 57.07
a5:/tmp 121 > xx.pl soft xx
Soft Parse %: 99.64
a5:/tmp 122 >
Enjoy, have FUN! H.Merijn
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-06-2003 07:12 AM
03-06-2003 07:12 AM
Re: script functionality
Here's another awk solution:
Create an awk script:
=======================
$0 ~ var{
p=index($0,var)
for (i=p+length(var)+4;i
}END{print}
=======================
then run using:
# awk -f awkscript var="Soft Parse" yourfile
99.64
# awk -f awkscript var="Buffer Nowait" yourfile
100.00
rgds, Robin