Solution for How do I move files out of a broken directory in linux?
is Given Below:
I know the premise of the question may be confusing, but I want to understand what happened.
Recently I have been experimenting with the rockchip OK3399 single-chip computer(see here) and have installed a linux system on it with TF card installation. Using Putty and connecting with serial protocol, I was able to establish a connection with the OK3399 computer and control it through my laptop.
I am trying to self-learn some linux with the OK3399 system. I created a bash code by the name of
displayvids.sh inside the directory
/usr/bin, which is meant to take a variable number of pictures with a mipi camera and then save in a directory for work.
I finished writing the code, but for some reason I cannot run the
.sh file when my working directory is not the
/usr/bin directory, despite
/usr/bin being in the
%PATH% environment variable. So, I executed the following command:
mv /usr/bin/display* /usr/local/bin
… attempting to move the file to
/usr/local/bin instead. The command ran successfully, but when I tried to run the command:
It tells me that I cannot cd to bin
As seen from the above image, the
/usr/local/bin is not even a directory. Why would mv succeed if the target was not a directory? How can I retrieve my bash file?
Why would mv succeed if the target was not a directory?
mv can also rename files:
mv foo.txt bar.txt
You renamed your script to
bin and moved it under
You may want to remember to add a trailing slash next time, to have
mv barf if the target isn’t a directory:
mv /usr/bin/display* /usr/local/bin/
How can I retrieve my bash file?
Rename it back.
mv bin displayvids.sh
For future reference, you can use the
file command to (try to) identify the contents of a file, if it’s installed:
would have probably said
bin: Bash script or similar.