Formatting bdf output

Hi All.

Using /usr/bin/ksh on a HP-UX B.11.23 ia64 system.

Executing the following ... ` bdf -t vfxs | grep "/" `

The output comes out like (in part) ...

/dev/vg00/lvol3     516096  229448  284480   45% /
/dev/vg00/lvol1     516096  211200  302560   41% /stand
/dev/vg00/lvol8    4710400 3613064 1091064   77% /var
/dev/vg01/lvol15   5120000 2859882 2118994   57% /usr1
/dev/vg00/lvol7    4096000 2568880 1515256   63% /usr
/dev/vg00/lvol4    1024000  455184  564800   45% /tmp
/dev/vg02/lvol21   12288000 8087722 3937812   67% /or2
....

I'd like to know how I might be able to left-justify all columns to reflect something similar to the following ...

/dev/vg00/lvol3     516096     229448     284480      45% /
/dev/vg00/lvol1     516096     211200     302560      41% /stand
/dev/vg00/lvol8     4710400    3613064    1091064     77% /var
/dev/vg01/lvol15    5120000    2859882    2118994     57% /usr1
/dev/vg00/lvol7     4096000    2568880    1515256     63% /usr
/dev/vg00/lvol4     1024000    455184     564800      45% /tmp
/dev/vg02/lvol21    12288000   8087722    3937812     67% /or2
....

The reason for the formatting is for presentation for non-tech personell.

Appreciate any feedback.

Cheers,
Cameron :slight_smile:

You can use printf to determine the width of the columns, something like:

awk '{printf("%-30s%-10s%-10s%-10s%-5s%-10s\n",$1,$2,$3,$4,$5,$6)}'

Regards

Hi Franklin52,

Many thanks for the reply and the awk statement.
I'm not at all conversed with anything awk.
Should I best perform a while loop to read a temp file containing the original output and have the awk output to a secondary file ??

Cheers,
Cameron

You can pipe the output to awk, it should be something like:

bdf -t vfxs | awk '/\//{printf("%-30s%-10s%-10s%-10s%-5s%-10s\n",$1,$2,$3,$4,$5,$6)}'

Regards

Hi again Franklin52,

Many thanks for the example. I'd heard awk was a powerful tool, just never knew how good.

Last question, but it is possible to format the 5th column right-justified by any remote chance ??

Cheers,
Cameron

Figured it out - either ...

bdf -l | awk '{printf("%-22s%-12s%-12s%-10s%5s %-10s\n",$1,$2,$3,$4,$5,$6)}'
-- or --
bdf -t vxfs | awk '{printf("%-22s%-12s%-12s%-10s%5s %-10s\n",$1,$2,$3,$4,$5,$6)}'

Many thanks Franlkin52 :b: