Tag Archives: Above Code

For Loop in shellscript – Printing Output for every iteration

Code:
for VGLIST in `lsvg -o`
do
CLOSED_OUT=`echo $VGLIST | lsvg -l $VGLIST | awk ‘{print $6 ” ” $7}’ | grep closed`
if [[ $? = 0 ]]; then
echo “Filesystems $CLOSED_OUT in VG that are in Closed status”
else
echo “n Some message”
fi
Above Code is working fine, but
Code:
echo “Filesystems $CLOSED_OUT in VG that are in Closed status”
is being printed for every iteration. I just want to print one line output for each filesystem that is closed in a particular volume group.
Source: The UNIX and Linux Forums