嗯,这是你可以使用的东西。它未在真实环境中进行测试,并且按原样提供 - 没有任何保证。 
# This script must run as root
if [ "$(id -u)" != "0" ]
then
    echo "This script must be run as root"
    exit 1
fi
source=/path/to/file
destination=Library/path/to/destination/directory
for u in /Users/*
do
    on=${u##*/}
    # If not a directory- do not process
    [ ! -d "$u" ] && continue
    # Check that the directory has a valid user name or do not process
    id "$on" >/dev/null 2>&1 || continue
    # Get the user's primary group id
    gn=$(id -gn "$on")
    # bug fix found by Alex Pilon
    # make destination directory if it doesn't exist
    install -o "$on" -g "$gn" -d "${u}/${destination}"
    install -b -o "$on" -g "$gn" -m 644 "$source" "${u}/${destination}"
done
 另一种解决方案基于bmike的建议 
# This script must run as root
if [ "$(id -u)" = "0" ]
then
    : running as root
else
    echo "This script must be run as root"
    exit 1
fi
source=/path/to/file
destination=Library/path/to/destination/directory 
dscl . -list /Users NFSHomeDirectory |
awk 'BEGIN { OFS=":" } / \/Users/ { print $1, $2 }' |
while IFS=: read u hdir
do
    # Get the user's primary group id
    gn=$(id -gn "$u")
    install -o "$u" -g "$gn" -d "${hdir}/${destination}"    
    install -b -o "$u" -g "$gn" -m 644 "$source" "${hdir}/${destination}"
done
               
              
dscl . -list /Users捕获不在/中的主目录的用户,然后为通过过滤器测试的用户请求NFSHomeDirectory(可能排除root和带有_的用户) -dscl . -read /Users/${u} NFSHomeDirectory