mv: cannot stat with *
Sebastian Wright
I've tried this before. I swear I was able to issue this kind of command before:
mv /home/user/temp1/* /home/user/temp2Basically, I got this command from here:
Any idea why it's telling me
mv: cannot stat `/home/user/temp1/*': No such file or directory 0 4 Answers
I can think of 2 possible reasons why this can happen:
- The source directory may not exist (OR)
- The source directory might be empty
Ignore if neither!
You need to use $USER for user to expand to your username. /home/user is only valid if you have a user named user. This will work if temp1 and temp2 exists in your home directory
mv /home/$USER/temp1/* /home/$USER/temp2 I'll try to help out and clear up the confusion a little:
If you want to move a folder and its contents to another one, you enter:
mv ~/Scripts ~/PodcastsIf you want to move a folder's contents but not the folder itself to another folder, you must enter, for example,
mv ~/Scripts/* ~/Podcasts. You can enterecho ~/Scripts/*to check the folder's content(If you also need to know about
globstar, which will allow you to recurse through all directory levels, see this article and this one. It can be enabled with shopt -s globstar, but that will need to be put in .bashrc to work permanently.)
(The tilde ~ in ~/Scripts is expanded to /home/mike/ or your user name automatically by the shell)
If you're using bash and the source directory is empty, you can modify the shell's default glob expansion behavior with:
shopt -s nullglobto enable the nullglob and cause any succeeding commands like mv to behave properly when the source directory is empty. Beware that this can cause other commands such as ls to behave unexpectedly.
You can disable the nullglob again with:
shopt -u nullglob