I executed the following command, intending to move the file into a subdirectory.
sudo mv myFile.jar hexara/*
Should I have used the following syntax instead?
sudo mv myFile.jar hexara
or?
sudo mv myFile.jar hexara/
Sudo is being invoked because I am in an area where the account does not have write privileges. I'm using SSH to work in a remote server.
In any event, after this, an ls
of the subfolder hexara shows that the file I moved is not there and that many files in the hexara directory are now missing. Previously there were three subfolders and an index.htm file, but now only one subfolder remains.
Did my malformed mv command cause the files to disappear, or should I suspect some other form of glitch or a different error was made? There were intervening commands--I navigated to another area and returned before cd'ing into hexara and discovering the loss, and made a copy of the CLI if that is of any help.
Is something like this recoverable?
An ls -al
showed the following:
phil@ladonax:/var/lib/jetty9/webapps/hexara$ ls -al
total 12
drwxr-xr-x 3 jetty adm 4096 Jun 30 10:26 .
drwxr-xr-x 6 jetty adm 4096 Jun 30 10:26 ..
drwxr-xr-x 4 jetty adm 4096 Jun 30 10:26 VSL
VSL, by the way, has 14 files in it, so I don't know where the above "total 12" comes from. The hexara directory might have had three subfolders and only one file in it before the loss. But I don't see why this would have turned up in the "total" but not appear in the accompanying listing.
Fortunately I have backup files of this directory. But I'm really puzzled as to what happened. Am using Ubuntu 20.04.
Yes, there is a task on the queue to upgrade Jetty but I assume that would not have any pertinence to this question.
EDIT: I discovered that all the files in the hexara subdirectory were moved into hexara/VSL. Any thoughts as to why ../webapps $ mv myFile.jar hexara/*
would cause files in ../webapps/hexara
to be moved into ../webapps/hexara/VSL
?
mv
usage, it takes only seconds to create a couple empty testfiles and test directories to verify that your syntax does what you expect. Be sure before usingsudo
. "Hmmm...let's make sure first" is the motto of a true professional.ls
since that will show all files themv
will move :)