Hi,
I am having a problem with getting subtotals after I have sorted and grouped data based on the first field.
Here is a small example of my input data:
/u01:ALPS:200000:100000:100000
/u02:UNDO:500000:200000:300000
/u02:SYSTEM:100000:100000:0
/u01:INDEX:300000:100000:200000
/usr:TRAIN:100000:50000:50000
I can get my output formated correctly with the exception of subtotals. For example this is a small example of what I been able to do so far.
FS Allocated Used Free
/u01 200000 100000 100000
300000 100000 200000
/u02 500000 200000 300000
100000 100000 0
/usr 100000 50000 50000
I am trying to subtotal (/u01, then u02, and /usr) in the
blank space under each group. The following is the sort script that I have been able to run with success.
BEGIN { FS = ":"}
{ if ($1 != prev) {
print ""
prev = $1
} else
$1 = ""
printf("%-10s %7d %7d %7d\n",
$1, $3, $4, $5)}
Thanks in advance
John
I am having a problem with getting subtotals after I have sorted and grouped data based on the first field.
Here is a small example of my input data:
/u01:ALPS:200000:100000:100000
/u02:UNDO:500000:200000:300000
/u02:SYSTEM:100000:100000:0
/u01:INDEX:300000:100000:200000
/usr:TRAIN:100000:50000:50000
I can get my output formated correctly with the exception of subtotals. For example this is a small example of what I been able to do so far.
FS Allocated Used Free
/u01 200000 100000 100000
300000 100000 200000
/u02 500000 200000 300000
100000 100000 0
/usr 100000 50000 50000
I am trying to subtotal (/u01, then u02, and /usr) in the
blank space under each group. The following is the sort script that I have been able to run with success.
BEGIN { FS = ":"}
{ if ($1 != prev) {
print ""
prev = $1
} else
$1 = ""
printf("%-10s %7d %7d %7d\n",
$1, $3, $4, $5)}
Thanks in advance
John