OS: AIX 7100-04-1216
So basically I'm trying to write a for loop that sees which volumegroups I have on my system, which filesystems reside in those volume groups and what the size of each of those filesystems is.
I have following code:
for LINE in `lsvg` ; do
echo "Volume Group: "${LINE}
for LINE2 in `lsvgfs ${LINE}` ; do
echo "`lsvgfs ${LINE}` \n"
df -g ${LINE2}
done
done
The output of lsvg
rootvg
nimvg
The output of lsvgfs (for rootvg)
/
/usr
The output of lsvgfs (for nimvg)
/export/nim/lpp_source
/export/nim/spot
The output of df -g (for / in volumegroup rootvg)
Filesystem GB blocks Free %Used Iused %Iused Mounted on
/dev/hd4 5.25 2.86 46% 9957 2% /
The output of df -g (for /usr in volumegroup rootvg)
Filesystem GB blocks Free %Used Iused %Iused Mounted on
/dev/hd2 2.00 0.17 92% 43194 50% /usr
The output of df -g (for /export/nim/lpp_source in volumegroup nimvg)
Filesystem GB blocks Free %Used Iused %Iused Mounted on
/dev/fslv02 10.00 8.24 18% 597 1% /export/nim/lpp_source
The output of df -g (for /export/nim/spot in volumegroup nimvg)
Filesystem GB blocks Free %Used Iused %Iused Mounted on
/dev/hd4 5.25 2.86 46% 9957 2% /
What it should do:
Volume Group: rootvg
File System: /
/dev/hd4 5.25 2.86 46% 9957 2% /
File System: /usr
/dev/hd2 2.00 0.17 92% 43194 50% /usr
File System: /var
Volume Group: nimvg
File system: /export/nim/lpp_source
/dev/fslv02 10.00 8.24 18% 597 1% /export/nim/lpp_source
File system: /export/nim/spot
/dev/hd4 5.25 2.86 46% 9957 2% /
What I get:
Volume Group: rootvg
/
/usr
Filesystem GB blocks Free %Used Iused %Iused Mounted on
/dev/hd4 5.25 2.86 46% 9957 2% /
/
/usr
Filesystem GB blocks Free %Used Iused %Iused Mounted on
/dev/hd2 2.00 0.17 92% 43194 50% /usr
Volume Group: nimvg
/export/nim/lpp_source
/export/nim/spot
Filesystem GB blocks Free %Used Iused %Iused Mounted on
/dev/fslv02 10.00 8.24 18% 597 1% /export/nim/lpp_source
/export/nim/lpp_source
/export/nim/spot
Filesystem GB blocks Free %Used Iused %Iused Mounted on
/dev/hd4 5.25 2.86 46% 9957 2% /
-g
option fordf
doesn't exist on GNUdf
so that was confusing as is yourecho \n
which will print a literal\n
(not a newline) on all systems I am familiar with. Does it work as expected on AIX? Without the-e
flag? Finally, where doesFile System
come from? It does not appear in the output examples or your loop. – terdon♦ Jul 14 '14 at 12:56