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.
 
Thread 'Urgent: Physically repair - or bypass - power button on Asus laptop'
Asus Vivobook S14 flip. The power button is wrecked. Unable to turn it on AT ALL. We can get into how and why it got wrecked later, but suffice to say a kitchen knife was involved: These buttons do want to NOT come off, not like other lappies, where they can snap in and out. And they sure don't go back on. So, in the absence of a longer-term solution that might involve a replacement, is there any way I can activate the power button, like with a paperclip or wire or something? It looks...
I came across a video regarding the use of AI/ML to work through complex datasets to determine complicated protein structures. It is a promising and beneficial use of AI/ML. AlphaFold - The Most Useful Thing AI Has Ever Done https://www.ebi.ac.uk/training/online/courses/alphafold/an-introductory-guide-to-its-strengths-and-limitations/what-is-alphafold/ https://en.wikipedia.org/wiki/AlphaFold https://deepmind.google/about/ Edit/update: The AlphaFold article in Nature John Jumper...
Back
Top