You seem on the ball so I won't spoon-feed you a script, but here are some pointers:
- You're using - awkincorrectly. Try this instead:- awk -F: -v uid_min=${UID_MIN:-1000} '$3%2==0 && $3>uid_min && $3!=65534{print $6}' /etc/passwd
- There's no need for - cat.
- Use your - awkoutput as the input to your- readloop, ie.- while read USER_HOME_DIR ; do ... ; done < $(awk...). Understand that this will mean that only one- awkprocess needs to be spawned, while your original script spawns a separate- awkprocess for each line, so this is much more efficient.
- Add a check in your - awkprogram to limit it to UID's above 1000, or you will inadvertently perform your copy for many system users.
- Note that in #1 above, I changed your - $1to- $6in order to pull the user's home directory instead of the user's name.
- I just noticed on my debian machine that there exists a 'nobody' user with UID 65534, so you may need to account for that. I modified the - awkstatement in #1 accordingly.
- As per user Jeff Schaller's comment, I've modified the - awkprogram to account for a custom minimum UID. The form- ${UID_MIN:-1000}means set the value as 1000 if it would otherwise be null or unset.
 
                