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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem listing all files in a script

Status
Not open for further replies.

PSD

Instructor
Apr 25, 2000
392
0
0
GB
I knocked this together today but it is not listing all files in the while true FILE loop. I tried two variations, one with the ultimate endgame matching files which are go+w and one without. The idea is to check the files in each users home directory to ensure nothing is go+r.

lsuser -a home ALL |cut -f2 -d= | while read HOMEDIR; do [[ -d $HOMEDIR ]] && ls -a $HOMEDIR | grep -Ev "^.$|^..$" | while read FILE; do [[ -f $FILE ]] && ls -l "$HOMED
IR/$FILE"; done; done

#lsuser -a home ALL |cut -f2 -d= | while read HOMEDIR; do [[ -d $HOMEDIR ]] && ls -a $HOMEDIR | grep -Ev "^.$|^..$" | while read FILE; do [[ -f $FILE ]] && ls -l "$HOME
DIR/$FILE" |awk '{print $1 , $9}' |egrep '^-....w....|^-.......w.'; done; done

Any help is greatly appreciated.
 
Why not simply use the find command (-perm)?

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Good questions - because this is AIX and I cannot stop the find command traversing directories (only limit is filesytem boundaries)
 
I had to do something similar on AIX a short while back - this is how I formatted the find command so that it would only look in the specified directory:

Code:
SRC="/sourcedir"
DST="/destinationdir/"

cd $SRC
find . ! -name . -prune -type f -mmin -1 -exec cp {} $DST \;

If you use the above - specifically "find . ! -name . -prune" part and pair that up with -perm you should then be able to do what you want.

Add a little color to your PUTTY terminal: faq52-6627
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top