Use shopt -s dotglob
. It includes the dot files. It's a bash setting so will fix mv
command too.
https://unix.stackexchange.com/a/446353/346155
EDIT: the accepted answer correctly says rsync includes dot files by default. As this question is the top result from Google for "rsync dot files", my rsync command had failed. Whereas the OP had not tried using plain rsync, I often put an asterisk after the slash which is added to the end of a directory to ensure the dir doesnt get copied into the target dir, which happens when assuming the 'sync' in rsync will actually sync the dirs. So in my case, using the shell option for dotglob fixed my problem, and might fix yours. It also works on other wildcard matching of the /dir/*
kind. Personally, I think this is a more intuitive and explicit than using just the /, as just /dir/
could imply just completing a long list of dir separators, as it is interpreted when used with the target dir.
Further, I wonder if using this shell option by default would have any detrimental side effects, as it is not imposed in Bash by default. It's just part of the Unix design, I assume, that hidden files are not supposed to be copied or moved by default (again, unless using the /dir/
form). I would advocate for making all files copied the default, as that seems more intuitive and expected, unless there is a detrimental reason I'm missing (the only thing I can think of is having location specific information that one wouldnt want moved, or just wanting to copy media data from a dir instead of any config files - which I might argue are better to have copied than not).