1850171 Members
2321 Online
104050 Solutions
New Discussion

long lv names

 
SOLVED
Go to solution
Donald C Nelson
Frequent Advisor

long lv names

I have the following mount point below and I would like to know how would to write a script that would should the second line as part of the first line when I use the awk '{print $2}'

/dev/vg01/test_oracle_db 311296 1181 290740 0% /oracle_db
6 REPLIES 6
Rick Garland
Honored Contributor

Re: long lv names

I've used a perl script

Modify the last line, the printf statement, to display/print any or all of the fields from the bdf command.

File attached
Sandman!
Honored Contributor

Re: long lv names

Donald,

I'm not sure I understand what you mean. Could you clarify what kind of scripting help you need preferably with examples.

thanks!
Bill Hassell
Honored Contributor
Solution

Re: long lv names

Parsing bdf is always tricky when there are long device file of NFS names. Here is the simplest method in a script:

bdf | while read DEV KSIZE KUSED KFREE PCT MNT
do
if [ "$KSIZE" = "" ]
then
read KSIZE KUSED KFREE PCT MNT
fi
echo $DEV $KSIZE $KUSED $KFREE $PCT $MNT
done

Now, no matter whether the listing is one line or two lines, all the variables will be set correctly. The trick is testing for a null variable ($KSIZE) which will occur when the line is split.


Bill Hassell, sysadmin
Kent Ostby
Honored Contributor

Re: long lv names

Create a file called concat.awk that contains:

NF<4 {saveit=$0;daflag=1;next;}
NF>4 {if (daflag)
{print saveit,$0;dflag=0;}
else
{print $0}
}


then:

bdf | awk -f concat.awk


"Well, actually, she is a rocket scientist" -- Steve Martin in "Roxanne"
Kent Ostby
Honored Contributor

Re: long lv names

Hmmm .. slight change to concat.awk

NF<4 {saveit=$1;daflag=1;next;}
NF>4 {if (daflag)
{print saveit,$0;dflag=0;}
else
{print $0}
}


"Well, actually, she is a rocket scientist" -- Steve Martin in "Roxanne"
Donald C Nelson
Frequent Advisor

Re: long lv names

Bill Hassell's script did the trick.