[GNU+Linux] Moving The Whole Content Of A Directory Including The Hidden Files

Submitted by Eus
on September 20, 2008 - 11:01am

Hi Ho!

$ pwd
/home/eus/shared/

$ ls
./
../
inside/

$ ls inside
./
../
.a/
.b/
x/
y/

If I want to move the whole content of /home/eus/shared/inside/ into /home/eus/shared/ including the hidden files, what command should I issue?

I cannot do the following ones:
$ mv -i -- inside/. ./ (ERROR: cannot overwrite ./.)
$ mv -i -- inside/* ./ (ERROR: the hidden files are left out)

Well, I can do:
$ cd inside
$ find -maxdepth 1 -mindepth 1 -exec mv -i -- '{}' ../ ';'

But, is there a better way?

Thank you.

Best regards,
Eus

.[^.]*

on
September 20, 2008 - 11:19am

mv dir/* dir/.[^.]* .

but you will get a message if there is no match for one of the globs

Not better?

on
September 20, 2008 - 11:39am

Hi Ho!

IMHO, it's not better than the `find ...' because it will leave out the hidden files in the following case:

$ ls inside
./
../
.a/
.b/
..c/
..d/
...e/
x/
y/

But, your method instills an idea:
Is there a way to say `mv -i -- inside/{everything except ./ and ../}'?

Thank you.

Best regards,
Eus

cd inside /bin/mv -f * .*

Anonymous (not verified)
on
September 20, 2008 - 12:23pm

cd inside
/bin/mv -f * .* ..
(some complaints, but the work is done)

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.