<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Readable DF Script in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/readable-df-script/m-p/6256573#M496261</link>
    <description>&lt;P&gt;&amp;gt;get bdf to list all output per device on one line&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Bill has a bdfmegs script:&lt;/P&gt;&lt;P&gt;&lt;A target="_blank" href="http://h30499.www3.hp.com/t5/LVM-and-VxVM/rbdf-script/m-p/6180027#M51190"&gt;http://h30499.www3.hp.com/t5/LVM-and-VxVM/rbdf-script/m-p/6180027#M51190&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 01 Nov 2013 18:19:36 GMT</pubDate>
    <dc:creator>Dennis Handly</dc:creator>
    <dc:date>2013-11-01T18:19:36Z</dc:date>
    <item>
      <title>Readable DF Script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/readable-df-script/m-p/6256565#M496260</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;Recently I was asked by my DBA if there was a way to get bdf to list all output per device on one line. &amp;nbsp;The bdf man pages indicated that if the device name was too long that it would insert a newline after the device name and list the space on the next line. &amp;nbsp;Couple that with disk sizes that break the columnar display of the disk sizes adn you get a jumbled mess.&lt;/P&gt;
&lt;P&gt;I had just written a quick script in awk to consolidate that data for working with something else, so I wrote rdf (readable df) to meet our needs. &amp;nbsp;The script pipes the output from bdf into awk and reformats it to at least look nicer. &amp;nbsp;The default output lists the logical volume name, &amp;nbsp;all sizes formatted to two decimal places with a suffix, the percentage used, and the mount point. &amp;nbsp;Calling rdf with a -l option causes all sizes to be displayed in Kbytes- useful for judging relative size. &amp;nbsp;The decision to use the logical volume name stemmed from a desire to retain a level of identification but to shorten the name; this will not work well for environments that reuse names for logical volumes.&lt;/P&gt;
&lt;P&gt;One flaw this script has (just realized it) is that is assumes an LVM device name and grabs the third part of the device path. &amp;nbsp;If this is a direct drive mount or uses a volume manager that does not follow the /dev/&amp;lt;vg&amp;gt;/&amp;lt;lv&amp;gt; format then this will break.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Enjoy,&lt;/P&gt;
&lt;P&gt;Mike&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;#!/bin/sh
long=no
while [ "$1" != "" ]; do
  case $1 in
    -l )  long=yes ;;
  esac
  shift
done

/bin/bdf | /bin/awk -v long=$long '
function resize(size) {
  fix="KMGTE"
  place=1
  while (size &amp;gt;= 1000) {
    size = size / 1024.0
    place++
  }
  return sprintf("%5.2f%s", size, substr(fix, place, 1))
}

BEGIN {
  if (long == "yes") {
    sizestr="Kbytes"
    sizelen=12
  }
  else {
    sizestr="size"
    sizelen=7
  }
}

{
  line=$0
  if ($1 == "Filesystem") {
    fmtstr = sprintf("%%-15s %%%is %%%is %%%is %%5s %%s\n", sizelen, sizelen, sizelen)
    printf fmtstr, "Filesystem", sizestr, "used", "avail", "%used", "Mounted on"
  }
  else {
    if ($1 ~ /^\/.*/) {
      split($1, parts, "/")
      disk = parts[4]
    }
    if (length($2) &amp;gt; 0) {
      if ($1 ~ /^\/.*/) {
        size=$2
        used=$3
        free=$4
        perc=$5
      }
      else {
        size=$1
        used=$2
        free=$3
        perc=$4
      }
      mopos=index(line, "% /")+2
      mount=substr(line, mopos)
      if (long == "yes")
        printf fmtstr, disk, size, used, free, perc, mount
      else
        printf fmtstr, disk, resize(size), resize(used), resize(free), perc, mount
    }
  }
}
'&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;P.S. This thread has been moved from HP-UX-General to HP-UX-languages. -HP Forum Moderator&lt;/P&gt;</description>
      <pubDate>Mon, 04 Nov 2013 03:23:41 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/readable-df-script/m-p/6256565#M496260</guid>
      <dc:creator>MichaelWilmes</dc:creator>
      <dc:date>2013-11-04T03:23:41Z</dc:date>
    </item>
    <item>
      <title>Re: Readable DF Script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/readable-df-script/m-p/6256573#M496261</link>
      <description>&lt;P&gt;&amp;gt;get bdf to list all output per device on one line&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Bill has a bdfmegs script:&lt;/P&gt;&lt;P&gt;&lt;A target="_blank" href="http://h30499.www3.hp.com/t5/LVM-and-VxVM/rbdf-script/m-p/6180027#M51190"&gt;http://h30499.www3.hp.com/t5/LVM-and-VxVM/rbdf-script/m-p/6180027#M51190&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 01 Nov 2013 18:19:36 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/readable-df-script/m-p/6256573#M496261</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2013-11-01T18:19:36Z</dc:date>
    </item>
  </channel>
</rss>

