SiberianKhatru
ISP
I am trying to run a script which pulls out all users from the /etc/passwd file, subjects that list of users to exclusion criteria (removing system users from the list such as root, lp, sys etc) and produces a new list of users. I need to pass the new list of users to awk to determine the users home directories in the passwd file.
I then need to 'find' files in the users home directories which they own. This all sounds complicated because there are in-consistencies on the file system which deems this necessary.
So far I have set up variables:
############
CRITERIA='(^root|^bin|^sys|^lp|^uucp|^nuucp|^listen|^noaccess|^daemon)' # this sets out the list of not-needed users
USERS=`nawk -F: '$1 !~ /${CRITERIA}/ {print $1}' /etc/passwd` # this produces the new list variable
############
#The following attempts to pull out the home directories and search in those directories for files
############
for people in $USERS
do
HOME=`grep "^$people" /etc/passwd |nawk -F: ' {print $6}'`
find $HOME -user $people -exec ls -l {} \; | awk '$3 !~ /^root/ {print}'
done
############
My 'excluding root,lp etc users from my list is not recognised in awk - the original list of users is passed unaltered to the find command and all users have their home directories interogated.
What is my syntactical error?
I then need to 'find' files in the users home directories which they own. This all sounds complicated because there are in-consistencies on the file system which deems this necessary.
So far I have set up variables:
############
CRITERIA='(^root|^bin|^sys|^lp|^uucp|^nuucp|^listen|^noaccess|^daemon)' # this sets out the list of not-needed users
USERS=`nawk -F: '$1 !~ /${CRITERIA}/ {print $1}' /etc/passwd` # this produces the new list variable
############
#The following attempts to pull out the home directories and search in those directories for files
############
for people in $USERS
do
HOME=`grep "^$people" /etc/passwd |nawk -F: ' {print $6}'`
find $HOME -user $people -exec ls -l {} \; | awk '$3 !~ /^root/ {print}'
done
############
My 'excluding root,lp etc users from my list is not recognised in awk - the original list of users is passed unaltered to the find command and all users have their home directories interogated.
What is my syntactical error?