I have a bunch of files that have different extensions:
.png .fa .sh
which were in a directory called 'files'.
I wanted to move each
.png to images directory
.fa to fasta directory
.sh to upper directory Golden_Asian.git/
Moving the .png and .fa files worked well,
but for the .sh
file, when I did
mv files/*.sh Golden_Asian.git
it just made type POSIX shell script, ASCII text executable, with the name
Golden_Asian.git
the name of the original file was
script.sh
so I was supposed to get a result like
Golden_Asian.git/script.sh
Did I do something wrong or is it the right result?
The original file in the "files" directory has disappeared, so I'm pretty sure the file has been transferred to the right directory but don't understand why the name has been changed.
It's the right result if there was only one .sh
file and there was no directory called Golden_Asian.git
in the current directory. You executed mv files/script.sh Golden_Asian.git
, so it moved the file from the original name to the name you specified. If there was already a file Golden_Asian.git
in the current directory, it would be clobbered (replaced) by the new file. If there was a folder named Golden_Asian.git
in the current directory, you'd have a file Golden_Asian.git/script.sh
after the command. That's not what you got, so it is legitimate to deduce that you did not have a folder called Golden_Asian.git
in the current directory when you executed the command.
If you'd specified:
mv *.sh Golden_Asian.git/
then it would have required the directory to exist and the result would have been a file Golden_Asian.git/script.sh
. If you'd had more than one .sh
file, then you'd have needed the directory Golden_Asian.git
to exist. You said "upper directory"; did you intend to write:
mv *.sh ../Golden_Asian.git
If there was a directory in the parent directory called Golden_Asian.git
, then the script would have been moved there. If there was no directory, the file would have been moved up a level and renamed. Again, a trailing /
would have prevented confusion.
Note that moving a file into a GIT directory (especially a bare repository) is probably not a good idea.