I used the command
mv folder_name ....
I thought by using ..
twice, it would move it back two folders.
Unfortunately my files disappeared.
I need to recover them.
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It only takes a minute to sign up.
Sign up to join this communityYour directory is still there :)
You have renamed it ....
Because files whose names start with .
are hidden, you cannot see the directory unless you display hidden files
run
ls -A
and there it is!
Revert the change:
mv .... original_folder_name
and do the move correctly
mv original_folder_name ../..
The correct form would have been
mv folder_name ../..
You've moved your folder to a new folder named ....
; to recover your files, run
mv .... folder_name
Like many other commands, mv
is somewhat dangerous because mistakes can in some cases cause unrecoverable loss of data (except from backups): anything which ends up being interpreted as "move these files to this file" will cause all the files apart from the last one to be lost (each file will be renamed in turn to the target). To prevent such mistakes, there are a number of techniques:
-i
, which tells mv
to ask for confirmation before overwriting;-t
to specify the target folder (so mv
will only move to a target folder);/
at the end of the target folder's name.....
. For this reason I advise never to type commands of the form mv dir/* dest
. Commands whose prefixes are dangerous operations are bad news.
Feb 7, 2017 at 3:20
You just renamed your folder to ....
, and since it starts with .
, it's now hidden.
type mv .... foldername
to recover it
you can also type ls -la
to list it (since -a
prints hidden files)
The correct way to descend files and folder two directories is mv fileorfolder ../../
For future reference, if you add a / to the end of the path, then the command will fail if the target isn't a pre-existing directory, for example
mv foldername ..../
mkdir foo; mv foo bar/
and it still worked. bar
didn't exist prior to that.
history | grep mv
will show which command you have exactly use.....
!../..