PDA

View Full Version : Simple "mv" shell command question



nyinge
April 11th, 2007, 09:30 AM
Let's say I'm in a directory with many files and an empty folder (named "haha"). I want to move all the files into that empty folder. So, I'd issue:
mv * empty_folder It works but with a warning:
mv: cannot move `haha' to a subdirectory of itself, `haha/haha' Is there a better solution for such a case? Thank you.

Ramses de Norre
April 11th, 2007, 10:02 AM
find . -maxdepth 1 -type f -exec mv '{}' haha/ \;

nmsa
April 11th, 2007, 10:13 AM
ls
1/ 2 3
#1 is the folder

$ for i in `find $PWD -type f`
> do
> mv $i 1/
> done
$ ls
1
$ ls 1/
2 3