Terminal Mv command including hidden files

May 13, 2011    hidden files mac terminal mv command

I often forget how to do this, so this time im going to blog it so that I can always look back at it and hopefully it will also be helpful for everyone else.

Often when im moving files around on my development environment or remote servers I need to move files and folders back and forth, including important files such as .htaccess files.

A simple command like:

mv Folder/* .

Actually does not move hidden files, all be it moves all the rest.

I found two solutions.

Most linux machines will allow the following to set hidden files to be included. Note your regular move commands will now always include hidden files, if you do not want this then move on to the second solution.

shopt -s dotglob

And if not this works pretty nicely too

ls -A  | while read i; do mv /"$i" ; done

Hope this helps.

blog comments powered by Disqus