HP-UX bdf output three usage columns with awk

Archives
Tim Regan

HP-UX bdf output three usage columns with awk

Postby Tim Regan » Tue Feb 14, 2006 2:38 pm

Hello,

I am totaling the three usage columns from the output of bdf for a particular filesystem as in the example below:

# bdf /oralce/PS1/sapdata23 | awk 'BEGIN {total=0;used=0;avail=0} {total+=$2; used+=$3; avail+=$4} END {print "Totals: " total " " used " " avail " "}'

The ouput of this command looks like this:

Totals: 3.35573e+08 3.8466e+07 90

I would like to know if anyone can tell me how to generate the output without scientific notaion?

Thanks in advance,

Tim

Tim Regan

Re: HP-UX bdf output three usage columns with awk

Postby Tim Regan » Tue Feb 14, 2006 2:52 pm

Hello,

Ok I figured out the scientific notaion portion with the following modification:

bdf /oracle/PS1/sapdata23 | awk 'BEGIN {total=0;used=0;avail=0} {total+=$2; used+=$3; avail+=$4} END {printf "Total Kbytes Free: %f Total Kbytes Used: %f Total Kbytes Available: %f", total, used, avail }'

The ouput looks like this:

Total Kbytes Free: 7793456112.000000 Total Kbytes Used: 5103595920.000000 Total Kbytes Available: 2666181630.000000

My new question would be; how do I get rid of the decimal point and the trailing zeros from the output above?

Thanks in advance,

Tim

Tim Regan

Re: HP-UX bdf output three usage columns with awk

Postby Tim Regan » Tue Feb 14, 2006 4:37 pm

Hello,

Got it!

bdf /oracle/PS1/sapdata23 | awk 'BEGIN {total=0;used=0;avail=0} {total+=$2; used+=$3; avail+=$4} END {printf "Totals: %.0f %.0f %.0f
",total ,used ,avail}'

Totals: 7793456112 5002806767 2766183543

Thanks!


Return to “Archives”

Who is online

Users browsing this forum: Majestic-12 [Bot] and 2 guests