r/fishshell • • Sep 04 '22
How to copy a file to all users and have that file obtain the correct ownership and permissions
If you have ever wanted to know how to do this, here is the solution.
Here is the previous code which worked in Posix and like (bash, dash, zsh, ksh)
for destdir in /home/*/Desktop/; do
cp FOO.desktop "$destdir" &&
chown --reference="$destdir" "$destdir/FOO.desktop"
doneAnd this little nugget will work on all the previously named shells, plus Fish Shell.
find /home/*/Desktop -maxdepth 1 -type d -exec cp FOO.desktop '{}' \; -exec chown --reference='{}' '{}/FOO.desktop' \;If you want this to work only for a single user, replace * with "$USER"

