Operating System - HP-UX
1844876 Members
2040 Online
110233 Solutions
New Discussion

Another scripting problem

 
SOLVED
Go to solution
Adam Noble
Super Advisor

Another scripting problem

Hi all,

Somebody must have done this in the past. I have a problem whereby when I do a bdf the lvol and the filesystem are on different lines. I want to run a command for example that simply uses awk to put each lvol and relevant filesystem into a file. Thing is if I grep the lvol I lose the filesystem and vica versa. I thought about reading the output of bdf in line by line but still not sure how that would work.

Cheers
3 REPLIES 3
James R. Ferguson
Acclaimed Contributor
Solution

Re: Another scripting problem

Hi Adam:

Bill Hassell has an elegant script that accomodates your problem while making the standard 'bdf' much handier!

http://forums.itrc.hp.com/service/forums/questionanswer.do?threadId=1124262

Regards!

...JRF...
Hein van den Heuvel
Honored Contributor

Re: Another scripting problem

Yes, other folks have done this before :-)
Both stumbling into the line split, as well at taking the next step to tie the data up with lvm.

First step is to see wether 'df' instead of 'bdf' works for you.

Some prior posts with pointers to solutions:
(google: +awk +bdf +split +site:itrc.hp.com)

http://forums12.itrc.hp.com/service/forums/questionanswer.do?threadId=440647

http://forums12.itrc.hp.com/service/forums/questionanswer.do?threadId=1218175
Bill Hassell
Honored Contributor

Re: Another scripting problem

The simple answer is to use read to process each line from bdf and test if the 2nd value (total Kbytes) is null. If true, read again to pickup the rest of the values, something like this:

bdf | while read FS TOT USED AVAIL PERCENT MNT
do
[ "TOT" = "" ] && read TOT USED AVAIL PERCENT MNT

echo "$FS $TOT $USED $AVAIL $PERCENT $MNT"

done

The test for "TOT" triggers another read for line 2 to pickup the rest of the values. The echo line is just to show the one line results.



Bill Hassell, sysadmin