I have an overnight script which runs across a large directory to repair permissions and ownership. I also have this command output the list of files affected so that cron can email these as a log file. Previously I had the command in the form:
find /path/to/files -not -user myname -print -exec chown myname "{}" \;
As it is a long command sometimes I never receive a log email even though the ownership and permissions have changed, so I want to make the script more efficient. As such I have changed the command to:
find /path/to/files -not -user myname -print0 | xargs -0 chown myname
Is there anything I can do to that command so that it sill lists the files on standard output so that they will be emailed by cron in addition to piping them to xargs?
I cannot include the -print action in the find command as this will also be piped to xargs. Likewise if I include an -exec action with an echo command. Also I do not want to use the -t option with xargs as I just want the list of files and not the chown commands it generates.
The best solution I have been able to come up with is to use tee to ssave output in a temporary file to display afterwards, but I am hoping there is better solution.
Thanks,
Michael.