{"id":250,"date":"2012-06-07T15:20:26","date_gmt":"2012-06-07T20:20:26","guid":{"rendered":"http:\/\/www.hpux.ws\/?p=250"},"modified":"2012-06-08T15:32:47","modified_gmt":"2012-06-08T20:32:47","slug":"awk-trick-of-the-daymonth-parsing-bdf-output-awk-with-if-else-logic","status":"publish","type":"post","link":"https:\/\/www.hpux.ws\/?p=250","title":{"rendered":"awk trick of the day(month?) parsing bdf output. awk with if else logic"},"content":{"rendered":"<p>Ever try and do system reporting based on bdf?<\/p>\n<p>Annoying as all heck that sometimes the output is two line and sometimes one? I was forced to solve that problem today.<\/p>\n<p>&nbsp;<\/p>\n<p><strong>if [ &#8220;$OS&#8221; = &#8220;HP-UX&#8221; ]<\/strong><br \/>\n<strong>then<\/strong><br \/>\n<strong><\/strong><strong>\u00a0\u00a0 dcmd=bdf<\/strong><br \/>\n<strong>fi<\/strong><\/p>\n<p><strong>arraypointer=0<\/strong><br \/>\n<strong><\/strong><br \/>\n<strong>exec $dcmd | egrep -v &#8220;%used|\/dev\/deviceFileSystem&#8221; | awk &#8216;{lvn=$1;v=$2;if (v==&#8221;&#8221;) {getline;cap=$<\/strong><strong>1;ucap=$2;acap=$3;puse=$4;mp=$5;printf &#8220;%s %s %s %s %s %s\\n&#8221;, lvn,cap,ucap,acap,puse,mp} else {pr<\/strong><strong>intf &#8220;%s %s %s %s %s %s\\n&#8221;, $1,$2,$3,$4,$5,$6} }&#8217; | while read -r\u00a0 p1 p2 p3 p4 p5 p6<\/strong><br \/>\n<strong>do<\/strong><\/p>\n<p><strong>\u00a0\u00a0 #### calculations<\/strong><\/p>\n<p><strong>done<\/strong><\/p>\n<p>Typical bdf output:<\/p>\n<p>\/dev\/vg00\/lvol9\u00a0\u00a0\u00a0 4096000 3140019\u00a0 896285\u00a0\u00a0 78% \/var\/adm\/crash<br \/>\n\/dev\/vg_stgb1\/lvol1<br \/>\n1572765696 1382813225 178080447\u00a0\u00a0 89% \/steven05stgb<\/p>\n<p>More when the script is done<\/p>\n","protected":false},"excerpt":{"rendered":"<p>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. &nbsp; if [ &#8220;$OS&#8221; = &#8220;HP-UX&#8221; ] then \u00a0\u00a0 dcmd=bdf fi arraypointer=0 exec $dcmd | egrep -v &#8220;%used|\/dev\/deviceFileSystem&#8221; | awk &#8216;{lvn=$1;v=$2;if (v==&#8221;&#8221;) {getline;cap=$1;ucap=$2;acap=$3;puse=$4;mp=$5;printf &#8220;%s [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_bbp_topic_count":0,"_bbp_reply_count":0,"_bbp_total_topic_count":0,"_bbp_total_reply_count":0,"_bbp_voice_count":0,"_bbp_anonymous_reply_count":0,"_bbp_topic_count_hidden":0,"_bbp_reply_count_hidden":0,"_bbp_forum_subforum_count":0,"_kadence_starter_templates_imported_post":false,"footnotes":""},"categories":[],"tags":[],"class_list":["post-250","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/www.hpux.ws\/index.php?rest_route=\/wp\/v2\/posts\/250"}],"collection":[{"href":"https:\/\/www.hpux.ws\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.hpux.ws\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.hpux.ws\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.hpux.ws\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=250"}],"version-history":[{"count":0,"href":"https:\/\/www.hpux.ws\/index.php?rest_route=\/wp\/v2\/posts\/250\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.hpux.ws\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=250"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.hpux.ws\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=250"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.hpux.ws\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=250"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}