After my first encounter with a HP-UX system recently, I soon discovered that annoyingly, neither the df -h or df -g commands work in HP-UX! There are other commands such as df -PK or bdf I’ve found that can provide you with a more readable view of the filesystems, but after a bit of faffing around, I put this together instead:
df -Pk | awk '{ if ( NR == 1 ) { next } if ( NF == 6 ) { print } if ( NF == 5 ) { next } if ( NF == 1 ) { getline record; $0 = $0 record print $0 } }' | awk ' BEGIN {print "Filesystem Mount Point Total GB Avail GB Used GB Used" print "--------------------------------------------- ------------------------- ---------- ---------- ---------- -----"} END {print ""} /dev/ || /^[0-9a-zA-Z.]*:\// { printf ("%-45.45s %-25s %10.2f %10.2f %10.2f %4.0f%\n",$1,$6,$2/1024/1024,$4/1024/1024,$3/1024/1024,$5) }'
…which gives you something like this…
Filesystem Mount Point Total GB Avail GB Used GB Used ------------------------- ------------------------- ---------- ---------- ---------- ----- /dev/test01/db1 /u19 94.47 82.91 11.57 13% /dev/test02/log1 /u18 18.85 17.20 1.66 9% /dev/oemsg04/orasw /u07 74.06 23.97 50.10 68% /dev/oemsg04/db1 /u08 28.93 15.99 12.95 45% /dev/vg00/lvol5 /home 1.99 1.16 0.83 42% /dev/vg00/lvol6 /opt 9.96 4.74 5.22 53%
…mdfmegs comes over highly recommended alternative in the HP community, but as a quicker, on-the-fly fix, I’ve been using the above!
UPDATE: Script updated to account for filesystem paths being line wrapped!
Hope this helps…
Thank you for this! It helped me a lot.
To include NFS into output, use below code:
BEGIN {print "Filesystem Mount Point Total GB Avail GB Used GB Used"
print "----------------------------------- ------------------------- ---------- ---------- ---------- -----"}
END {print ""}
/dev/ || /^[0-9a-zA-Z.]*:\// {
printf ("%-35.35s %-25s %10.2f %10.2f %10.2f %4.0f%\n",$1,$6,$2/1024/1024,$4/1024/1024,$3/1024/1024,$5)
}
in linux:
df -h | column -t
mount | column -t
Gridlok,
Thanks for your comments. It helped me..
Thanks a ton for this. Really neat script!
Helpful!
What a great script! Thanks a lot =)
RAD! Thanks so much!
Thanks
Great! Thank you so much.
good one
Thank you so much!!!
I was so tired of gazing at the hpux df
This really worked magic for me, thanks.