I am looking for a way to copy uids and gids for all files of a directory tree from one machine to another. The directory tree is believed to be identical on both machines except that uids and gids got corrupted on the target machine.
The background is that I copied the tree with rsync some months ago, thereby erronously omitting the --numeric-ids option, which caused uids and gids to be wrong in the destination.
Something like
find . -printf "chown %U.%G '%p'\n"
that still works for file names that contain special characters, whitespace, and quotes.
0 Answers