0

尝试编写一个 Bash 脚本,将所有非管理员帐户拉入一个数组,然后我可以删除主目录rm -rf /Users/"$USER"并删除 Sys Pref user dscl . -delete /Users/"$USER"

我可以拉所有管理员,dscl . -read /Groups/admin GroupMembership | grep "$USER" | awk '{ print $3 }'但无法弄清楚拉非管理员的命令。

任何帮助都会很棒!

4

1 回答 1

0

You might be able to go about this differently.

  1. Use dscl to read all users in the directory and store results

    dscl . list /Users

  2. Use your current dscl call to return all admin users. Store results separate from step one

  3. Loop through results from step 1 and, on each pass, loop through results from step 2.
  4. if the user of the main loop does not match any of admin users, execute your deletions against that user.
于 2015-09-14T20:47:08.843 回答