What happened to my .txt files after accidentally using 'mv *' in UNIX?

  • Thread starter Thread starter cepheid
  • Start date Start date
  • Tags Tags
    Mistake Unix
AI Thread Summary
Using the command "mv *" without specifying a destination can lead to unintended file movements, particularly if the last item in the command is a directory. In this case, some .txt files may have been moved to that directory, while others remain in the original location. To recover lost files, checking for backups is advisable, as they may exist in other locations. To prevent future mistakes, it is recommended to use "cp" for copying files before deletion or to create an alias for the "mv" command that prompts for confirmation before overwriting files.
cepheid
Staff Emeritus
Science Advisor
Gold Member
Messages
5,197
Reaction score
38
Hi,

I was trying to type:

mv *.txt some_other_directory

but I accidentally hit 'return' after just typing:

mv *

Many of the .txt files in my current directory disappeared (but not all of them, strangely enough). Does anyone know what might have happened to them and how to undo the mistake?
 
Computer science news on Phys.org
The * is expanded by the shell into a list of files
So the mv command sees

mv a.txt b.txt c.txt d.txt e.txt
It then moves all the files to the last one if the last match is a directory, otherwise it should fail (at least on linux)
 
Last edited:
cepheid said:
how to undo the mistake?
Backups. Maybe you have copies of the files lying about in other places.
 
the lesson? never mv. cp and then del
 
Or alias mv so that it prompts before overwriting anything.
 
In my discussions elsewhere, I've noticed a lot of disagreement regarding AI. A question that comes up is, "Is AI hype?" Unfortunately, when this question is asked, the one asking, as far as I can tell, may mean one of three things which can lead to lots of confusion. I'll list them out now for clarity. 1. Can AI do everything a human can do and how close are we to that? 2. Are corporations and governments using the promise of AI to gain more power for themselves? 3. Are AI and transhumans...
Thread 'ChatGPT Examples, Good and Bad'
I've been experimenting with ChatGPT. Some results are good, some very very bad. I think examples can help expose the properties of this AI. Maybe you can post some of your favorite examples and tell us what they reveal about the properties of this AI. (I had problems with copy/paste of text and formatting, so I'm posting my examples as screen shots. That is a promising start. :smile: But then I provided values V=1, R1=1, R2=2, R3=3 and asked for the value of I. At first, it said...
Back
Top