Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

another "merge files"

Status
Not open for further replies.

linmac

Technical User
Aug 21, 2002
7
MY
hi all gurus,

I run 2 command to produce 2 outputfiles and want to merge together with some calculation:

1) command1 :-

time %usr %sys %wio %idle
05:05 50 47 5 5
...
...

2) command2 :-

user
54
45
65
user
load
min

what I want to do is to produce 1 output file which is

1) ouput command2, sometimes include etc. user or load or min, I want to replace those with the last number etc here is 65

2) then to produce output like below:

time %usr %sys %wio %idle %TOTAL user %USER
05:05 50 47 5 5 %usr+%sys+%wio 54 (user/285)*100
...
...
...

please help me, thanx in advance.
 
Sorry linmac, I don't understand what you want, especially what values to use from the second file.

CaKiwi

"I love mankind, it's people I can't stand" - Linus Van Pelt
 
hi CaKiwi, sorry for my very bad english.

ok, i want to produce 1 summary file, which is output from 2 commands (actualy "sar" command).


output file1 :-

time %usr %sys %wio %idle
05:05 50 47 15 5
05:10 45 30 25 15
05:20 30 27 35 15
...
...

output file2 :-

user
54
45
65
54
55 ****
load
min
min
min
min
50
30
20
...
...

I want 1 script to

1) replace all load/min/user string with the number before load/min/user string which in this case is 55 (*) in file1, and then

2) merge the 2 ouput files (file1 & file 2) to file3 which is (capital letters is new column) :


time %usr %sys %wio %TOTAL user %USER
05:05 50 47 5 %usr+%sys+%wio 54 (user/285)*100
^^^^^^^^^^^^^ ^^^^^^^^^^^^^
formula formula
............
.............
............
than you very much Cakiwi (in advance).
 
This doesn't do what you want but may get you started.

BEGIN {
while ((getline < &quot;file2.dat&quot;) > 0) {
if (flg) {
a[++n1] = $1
flg = 0
}
if ($1 ~ /user/) flg=1
if ($1 ~ /load/) b[++n2] = sv
sv = $0
}
print &quot;time %usr %sys %wio %TOTAL user %USER&quot;
}
NR>1 {
print $1,$2,$3,$2+$3+$4,a[NR-1],b[NR-1]/285*100
}

CaKiwi

&quot;I love mankind, it's people I can't stand&quot; - Linus Van Pelt
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top