Skip to main content
Question

Deleting a file from User Library

  • March 15, 2022
  • 1 reply
  • 5 views

mister_c
Forum|alt.badge.img+1

I put this together and all of it's pieces work fine when run in terminal. I just cannot get it to work when running it in JAMF. The $user seems to be the issue. When I add the user directory of the test Mac it works fine but without it I get a "No such file or directory" error. Can anyone see what I am doing wrong? The macOS is Monterey 12.1 if that helps

# Pull current logged in user into 'user' variable. user=`ls -l /dev/console | cut -d " " -f 4` # Delete User CCDA default preferences rm -R '/Users/$user/Library/Application Support/Adobe/OOBE/com.adobe.acc.container.default.prefs'

Any help would be appreciated.

1 reply

cdev
Forum|alt.badge.img+14
  • Contributor
  • March 15, 2022

Two things:

There are edge cases where your code for detecting the logged-in user will not properly report the user. Use instead:

user=$( echo "show State:/Users/ConsoleUser" | scutil | awk '/Name :/ && ! /loginwindow/ { print $3 }' )

 

Second, you are using single quotes in your rm statement, which in shell is literal characters. Change to double-quotes and it should work.