Hi Mark...here is another script which work well if I have to copy my preference file from an account named as "admin" or some other account. However, it not certain that all Mac machine will have a account named as "admin". This is why I am looking for a way to copy the preference file from /private/var location to all user accounts on a mac.
#!/bin/sh
localUsers=$( dscl . list /Users UniqueID | awk '$2 >= 501 {print $1}' | grep -v admin )
for userName in "$localUsers"; do
cp /Users/admin/Library/Preferences/org.mypreference.plist /Users/$userName/Library/Preferences/
chown $userName /Users/$userName/Library/Preferences/org.mypreference.plist
done
I tried to update it as suggest in some other forum like this, still no luck 😟
#!/bin/sh
UserAccounts=`dscl . list /Users UniqueID | awk '$2 > 500 { print $1 }'`
for userName in "$UserAccounts"; do
cp /private/var/org.mypreference.plist /Users/$userName/Library/Preferences/
chown $userName /Users/$userName/Library/Preferences/org.mypreference.plist
done
When I run the above script it comes up with the following error:
cp [-R [-H | -L | -P]] [-fi | -n] [-apvX] source_file target_file
cp [-R [-H | -L | -P]] [-fi | -n] [-apvX] source_file ... target_directory
chown: admin: No such file or directory
chown: admin/Library/Preferences/org.mypreference.plist: No such file or directory