Skip to main content
3 of 6
account for nobody
user1404316
  • 3.1k
  • 15
  • 23

You seem on the ball so I won't spoon-feed you a script, but here are some pointers:

  1. You're using awk incorrectly. Try this instead:

     awk -F: '$3%2==0 && $3>1000 && $3!=65534{print $6}' /etc/passwd
    
  2. There's no need for cat.

  3. Use your awk output as the input to your read loop, ie. while read USER_HOME_DIR ; do ... ; done < $(awk...).

  4. Add a check in your awk program to limit it to UID's above 1000, or you will inadvertently perform your copy for many system users.

  5. Note that in #1 above, I changed your $1 to $6 in order to pull the user's home directory instead of the user's name.

  6. 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 awk statement in #1 accordingly.

user1404316
  • 3.1k
  • 15
  • 23