Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I used the command below to move my data to a directory:

find . -name '*.mat' -exec mv {} ./ooutputs \;

However the directory of ./ooutputs does not exist. A file named ootputs is then created which I cannot open.

Is there anyway to retrieve the data inside the file?

Many thanks.


share|improve this question

Unfortunately, when the target for the mv command is not an existing directory, it renames the source file as the target; when used within a find command, that means each successive file that matches the predicate will overwrite the previous one. So in your case, the ./ooutputs file will now contain only the contents of the last .mat file that was matched. To avoid accidents like this it's good practice to always include a trailing slash character when you are moving files to a new directory i.e.

find . -name '*.mat' -exec mv {} ./ooutputs/ \;

since this will throw an error if /ooutputs is not in fact an existing directory. I don't know of a way to recover the other files except from backups - sorry.

share|improve this answer
@user2559061 welcome in AskUbuntu, this answer is for me the perfect answer to your question, if you share this point of view, I suggest you to mark this answer as Accepted that way it will help other users having same problem to know that this is the right answer. – Boris Oct 5 '13 at 7:09
Thanks for the answer. – user2559061 Oct 5 '13 at 7:50

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.