Problem with for loop in bash

I'm trying to do a script where I want to see if all users home directories are only writable by owner. However, in my script I do not know how to implement the for loop so that all directories are checked. In mine, I am only checking the permissions for the first directory found. I do know that a for loop is needed. Appreciate any advice given :slight_smile:

#!/usr/bin/bash
clear
awk -F: '{ print $6 }' /etc/passwd | uniq -u |
while IFS= read DIR
do

   VAR=`ls -ld $DIR | awk '{ print $1 }'`

   echo $DIR
   echo $VAR

   G=${VAR:5:1}
   O=${VAR:8:1}

   if [ "$G" == "-" ] && [ "$O"=="-" ] #success
   then
      echo "Directory only writable by owner"
   fi

done 

Jean-Pierre.

awk -F: '{ print $6 }' /etc/passwd | uniq -u  |xargs ls -ld |awk '! /^d.w..-..-/ {print $NF,"is not writable by owner"} '

hmm okay, then the problem now is i only want to print one line of "PASS" (all only writable by owner) or "FAILED" (1 or more directories writable by group/owner )