msgbartop
Tips and Tricks site for advanced HP-UX Engineers
msgbarbottom

07 Jun 12 awk trick of the day(month?) parsing bdf output. awk with if else logic

Ever try and do system reporting based on bdf?

Annoying as all heck that sometimes the output is two line and sometimes one? I was forced to solve that problem today.

 

if [ “$OS” = “HP-UX” ]
then
   dcmd=bdf
fi

arraypointer=0

exec $dcmd | egrep -v “%used|/dev/deviceFileSystem” | awk ‘{lvn=$1;v=$2;if (v==””) {getline;cap=$1;ucap=$2;acap=$3;puse=$4;mp=$5;printf “%s %s %s %s %s %s\n”, lvn,cap,ucap,acap,puse,mp} else {printf “%s %s %s %s %s %s\n”, $1,$2,$3,$4,$5,$6} }’ | while read -r  p1 p2 p3 p4 p5 p6
do

   #### calculations

done

Typical bdf output:

/dev/vg00/lvol9    4096000 3140019  896285   78% /var/adm/crash
/dev/vg_stgb1/lvol1
1572765696 1382813225 178080447   89% /steven05stgb

More when the script is done

Tags: , , , ,

sidebarbottom
sidebartop
sidebarbottom
WhatsApp chat