I have accidentally run mv
command in folder to rename files. But I have forgot to specify absolute path (I did just mv old_name new_name
). Now the files are gone. Any idea where those files are?
Thanks for any help.
They'll be in the same directory, if you didn't provide any directory designation such as .. or ../..
So mv oldFile newFile
stays in the same directory (basically renaming it),
Note: If newFile already existed, you've just overwritten it - mv won't ask before doing so unless you supply -i
as an argument.
mv oldFile ../newFile
moves it into the parent directory,
mv oldFile ./existingSubDirectory/newFile
moves it into the directory existingSubDirectory with the newFile name,
mv oldFile -p ./newSubDirectory/newFile
creates the new subdirectory called 'newSubDirectory' and puts the newFile within it.
You can combine to do some very weird (and generally pointless) directory traversal such as mv oldFile ././././../../dev/null
if you really wanted, but there's very little point.
If you did not specify a full path they're in position relative to the path you worked on.
If you're in your users directory (/home/user
) and run mv myfile newfile
while being in that directory the file is renamed to newfile
. If it exists it's overwritten. If you specified part of a path (mv myfile something/newfile
) and the folder did not exist, you'd get an error. If you supplied -p
the folder something
would've been created.
If you do know the name you could use find
or some other utility to find the file (on Debian you could use locate
).
history
, and you can see exactly what move command you actually ran. Usehistory | less
if you've typed so much you can't see the history in full anymore. - Did you run this command multiple times on different files, with the same 'new_name' ?ll
is an alias which may not exist, usels -a
to display all files including those starting with . (hidden).