I'm attempting to create a script to remove .app files from User's trash bins. I have the following script that is returning "No such file or directory."
#!/bin/bash
# for each user in the /Users folder that is (!)not the Shared folder
for dir in /Users/[!Shared]*
do
# Create a variable with just the users name
loggedInUser=$( scutil <<< "show State:/Users/ConsoleUser" | awk '/Name :/ && ! /loginwindow/ { print $3 }' )
# Delete app files from the currect user's trash
rm -R /Users/${loggedInUser}/.Trash/*.app
# For logs or viewing progress--shows when the users trash has been emptied
echo -e ".app files removed from Trash for: ${loggedInUser}"
done
Has anyone done something like this?