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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problems with END

Status
Not open for further replies.

namaycushs

Technical User
Aug 10, 2004
7
0
0
CH
Hi,
I want to calculate the total allocated, free and used space for all filesystems which have dsk in their path.

I tried this:

df -k | awk ' /dsk/{
{ for (i=1; i<=NF; i++)
summe += $i/1024/1024
}
sum_zeile = "Summe:"
for (i=2; i<= 4; i++)
sum_zeile = sum_zeile "\t" summe
print sum_zeile}'

Where "Summe" means sum. As a result I get the accumulated sum for every line. How do I get the overall-total in one line i.e. above command | tail -1
I tried END {sum_zeile...} but this didn't work out. Why ?
 
I tried END {sum_zeile...} but this didn't work
Can you please post the awk script you tried with the input data and the expected result ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
I made no Skript, but gave in the command as posted.
Input data in Pseudocode form the command df -k in UNIX:

/dev/../dsk/...numberi1 numberj1 numberk1
.
.
./dev/../dsk/..numberin numberjn numberkn

#where all numbers are in kb
Desired Output:
Sum: number in, number jn, nummber kn








 
Which awk code or program or script doesn't works ?
The df -k output vary depending of the unix flavor, so, please post your input date and the awk snippet and the expected result with the posted input data.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top