bash moving hidden files, reset dotglob?

Yes, you would have to unset those options (with shopt -u nullglob dotglob) afterwards if you wanted the default globbing behaviour back in the current shell.

You could just do

mv ~/public/* ~/public/.* ~/public_html/

That would still generate an error without nullglob set if one of the patterns didn't match anything, obviously, but would work without having to set either option. It would probably also say something about failing to rename . since it's a directory, but that too isn't stopping it from moving the files.

A better option may be to use rsync locally:

rsync -av ~/public/ ~/public_html/

and then delete ~/public.


Simply unset them:

shopt -u dotglob nullglob

don_crissti makes a good point that I'll elaborate on. It's not clear from the question if either dotglob or nullglob were already set before running shopt -s to set them. Thus, blindly un-setting them may not be the proper reset to do. Setting them in a subshell would leave the current shell's settings unchanged:

( shopt -s dotglob nullglob; mv ~/public/* ~/public_html/ )

Tags:

Bash

Mv

Dot Files