Today we needed to copy a file to a whole bunch of users home folders, and fix the permissions after copying.
Here’s what I came up with:
ls -A | xargs -n 1 -IUSERNAME cp source_file.txt ~USERNAME/eportfolio
ls -A | xargs -n 1 -IUSERNAME chown USERNAME.staff ~USERNAME/eportfolio/source_file.txt
ls -A | xargs -n 1 -IUSERNAME chmod 664 ~USERNAME/eportfolio/source_file.txt
The cwd was the directory containing the home directories for the users I wanted to copy the file to.
