I'm upgrading custom PDF options in both the root library and user library and need a way to delete the existing files I've come across a script working till it tries to use the user$ variable in the file path. Trying to figure out what I'm doing wrong or if there is a better way to do this. Here is the script:
#!/bin/bash
# Get a list of users, filtering out service accounts, root, daemon, and nobody...
#
users=$(dscl . list /Users | grep -v -e '_' -e 'root' -e 'daemon' -e 'nobody')
# Loop through the list of users.
for user in [$users]; do
# Put the path to the directory in a variable.
# The quotes escape the spaces.
#
[ $dir= ]"/Users/$user/Library/Application\\ Support/Adobe/Adobe\\ PDF/Settings"
# For each $user, delete the directory if it exists.
if [ -d "$dir" ]; then
rm -rf "$dir"
fi
done