Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help with array

Status
Not open for further replies.

bgs

MIS
May 6, 2002
4
US
I am trying to show the results of df -k on HP for 1 to n filesystems on one line for each filesystem.

df -k results are as follows
/opt/app (/dev/vg1001/lv100102 ) : 14703148 total allocated Kb
3393810 free allocated Kb
11309338 used allocated Kb
76 % allocation used

I want to do a df -k for all of a type of file systems "/dba/appl01" --- /dba/applxx" and have the results like the following
/dba/appl01 123456 123456 123456
....
/dba/applxx 123456 123456 123456

Here is what I am try to use but I think my problem is getting the info into an array and then knowing how to get out the filesystem and other space numbers correctly.
This is being run from a ksh script to report space info.
ListEachFs()
{
set -vx
ls -ld /dba/*|grep -i oracle|awk '{print $9}'|sort|while read FileSys;do
df -k $FileSys|grep -i &quot;allocated Kb&quot;|awk '{ for ( x = 1; x <= NR; x++ ) arr[x] = $0} END{ for (d in arr) if ($d ~ /allocated/ ) print $d, arr[d]}'
done
}

I use the &quot;ls -ld /dba/*|grep -i oracle|awk '{print $9}'&quot; to only get mounted fs's in a cluster system.

When I run the above all I get is the &quot;used allocated Kb&quot; line for all filesystems.
I have searched forums, books, web etc.. and I still can not get the right syntax combinations.
Lots of help showing functions etc.. is beyond me still. Any help will be greatly appreciated.
 
I'm not sure if I understand exactly what you want and this is untested, but it may get you started.

df -k $FileSys|awk -v fs=$FileSys '{printf fs,$(NF-3) &quot; &quot;;getline;printf $1 &quot; &quot;;getline;print $1;exit}' CaKiwi
 
I thought it was going to be more difficult.

Thanks for the help.[smile]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top