As others have said, you are probably running your command on an empty directory. Another way of doing this (that will simply fail silently on an empty directory) is to use find
's -exec
action:
find . -exec mv '{}' ../ \;
This will give you an error:
mv: cannot move `./' to `../.': Device or resource busy
This is because I am not restricting find
by file type so it will also attempt to move the current directory (.
) and fail. You can safely ignore this error, or you can specify you want all types of files and folders:
find . \( -type f -o -type d \) -exec echo '{}' ../ \;
From man find
:
-exec command ;
Execute command; true if 0 status is returned.
All following arguments to find are taken to
be arguments to the command until an argument
consisting of `;' is encountered. The string
`{}' is replaced by the current file name
being processed everywhere it occurs in the
arguments to the command, not just in argu‐
ments where it is alone, as in some versions
of find. Both of these constructions might
need to be escaped (with a `\') or quoted to
protect them from expansion by the shell.
cool...I got it sorted thank you. For some reason it actually moved the files, amongst all the errors I got. But thank you for the tip – DextrousDave – 2013-07-06T12:58:07.393
1
You may also find this page useful for future reference (that whole website is a very good reference for working with bash).
– evilsoup – 2013-07-06T13:04:50.653