mv Command Deleted Files In Source Directory and Target DirectoryCreating a directory of recently created filesHow detect and run a shell script when any file or folder is being copied/moved to a directory?Traverse file system and move filesDeleted $WORK DirectoryFile got deleted when moving to parent directoryHow to copy files from one directory to another after closing the Dolphin file manager in Kubuntu 16.04 LTS?Change Encoding and Move Files in ONE bash Scriptcan Ijust replace /dev/ptmx, /dev/pts/* and fix the terminal issue after deleting one of these files?Cannot source .nanorc correctly: command “include” not foundMoving files accidentally to an not existing directory erases files?

Delete the following space

Has the US government provided details on plans to deal with AIDS and childhood cancer?

UX writing: When to use "we"?

How to get Planck length in meters to 6 decimal places

If the Moon were impacted by a suitably sized meteor, how long would it take to impact the Earth?

Why are prop blades not shaped like household fan blades?

Should students have access to past exams or an exam bank?

Derivative is just speed of change?

Is it unprofessional to mention your cover letter and resume are best viewed in Chrome?

Russian pronunciation of /etc (a directory)

"Will flex for food". What does this phrase mean?

Is the EU really banning "toxic propellants" in 2020? How is that going to work?

How to crop this photo of water drops on a leaf to improve the composition?

Backpacking with incontinence

May a hotel provide accommodation for fewer people than booked?

Applying for mortgage when living together but only one will be on the mortgage

"Fewer errors means better products" or "Fewer errors mean better products"?

What is the name of this type of figure?

Why are sugars in whole fruits not digested the same way sugars in juice are?

Why don't short runways use ramps for takeoff?

mv Command Deleted Files In Source Directory and Target Directory

Why should I use a big powerstone instead of smaller ones?

Why did the United States not resort to nuclear weapons in Vietnam?

Disease transmitted by postage stamps



mv Command Deleted Files In Source Directory and Target Directory


Creating a directory of recently created filesHow detect and run a shell script when any file or folder is being copied/moved to a directory?Traverse file system and move filesDeleted $WORK DirectoryFile got deleted when moving to parent directoryHow to copy files from one directory to another after closing the Dolphin file manager in Kubuntu 16.04 LTS?Change Encoding and Move Files in ONE bash Scriptcan Ijust replace /dev/ptmx, /dev/pts/* and fix the terminal issue after deleting one of these files?Cannot source .nanorc correctly: command “include” not foundMoving files accidentally to an not existing directory erases files?






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








2















I ran the mv command to move two files, let's call them file_name_1, file_name_2.
The command I used was:



mv file_name* /u/projects/lib


My assumption was that this would move both files into the lib directory.
What ended up happening was that file_name_2 got moved correctly but file_name_1 was deleted from the directory I was moving it from and the directory I was moving it to.



Losing the file wasn't a big deal as I was able to recover the file from a backup and did not lose any work but I am curious as to why this would happen and what would be the best way to prevent it from happening again? (For now I'm just copying the files over and then deleting the source file once I am sure it copied over fine)










share|improve this question







New contributor



Scott Gersbank is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





















  • The behavior you assumed is the actual one, both files should have been move to /u/projects/lib. Sometime it helps to try echo command... first to see what file expansion does before running the command. Btw, your target directory name is unusual. Are you on native Ubuntu or is this WSL or else?

    – xenoid
    8 hours ago

















2















I ran the mv command to move two files, let's call them file_name_1, file_name_2.
The command I used was:



mv file_name* /u/projects/lib


My assumption was that this would move both files into the lib directory.
What ended up happening was that file_name_2 got moved correctly but file_name_1 was deleted from the directory I was moving it from and the directory I was moving it to.



Losing the file wasn't a big deal as I was able to recover the file from a backup and did not lose any work but I am curious as to why this would happen and what would be the best way to prevent it from happening again? (For now I'm just copying the files over and then deleting the source file once I am sure it copied over fine)










share|improve this question







New contributor



Scott Gersbank is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





















  • The behavior you assumed is the actual one, both files should have been move to /u/projects/lib. Sometime it helps to try echo command... first to see what file expansion does before running the command. Btw, your target directory name is unusual. Are you on native Ubuntu or is this WSL or else?

    – xenoid
    8 hours ago













2












2








2








I ran the mv command to move two files, let's call them file_name_1, file_name_2.
The command I used was:



mv file_name* /u/projects/lib


My assumption was that this would move both files into the lib directory.
What ended up happening was that file_name_2 got moved correctly but file_name_1 was deleted from the directory I was moving it from and the directory I was moving it to.



Losing the file wasn't a big deal as I was able to recover the file from a backup and did not lose any work but I am curious as to why this would happen and what would be the best way to prevent it from happening again? (For now I'm just copying the files over and then deleting the source file once I am sure it copied over fine)










share|improve this question







New contributor



Scott Gersbank is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











I ran the mv command to move two files, let's call them file_name_1, file_name_2.
The command I used was:



mv file_name* /u/projects/lib


My assumption was that this would move both files into the lib directory.
What ended up happening was that file_name_2 got moved correctly but file_name_1 was deleted from the directory I was moving it from and the directory I was moving it to.



Losing the file wasn't a big deal as I was able to recover the file from a backup and did not lose any work but I am curious as to why this would happen and what would be the best way to prevent it from happening again? (For now I'm just copying the files over and then deleting the source file once I am sure it copied over fine)







16.04 command-line bash






share|improve this question







New contributor



Scott Gersbank is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.










share|improve this question







New contributor



Scott Gersbank is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.








share|improve this question




share|improve this question






New contributor



Scott Gersbank is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.








asked 8 hours ago









Scott GersbankScott Gersbank

111 bronze badge




111 bronze badge




New contributor



Scott Gersbank is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.




New contributor




Scott Gersbank is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

















  • The behavior you assumed is the actual one, both files should have been move to /u/projects/lib. Sometime it helps to try echo command... first to see what file expansion does before running the command. Btw, your target directory name is unusual. Are you on native Ubuntu or is this WSL or else?

    – xenoid
    8 hours ago

















  • The behavior you assumed is the actual one, both files should have been move to /u/projects/lib. Sometime it helps to try echo command... first to see what file expansion does before running the command. Btw, your target directory name is unusual. Are you on native Ubuntu or is this WSL or else?

    – xenoid
    8 hours ago
















The behavior you assumed is the actual one, both files should have been move to /u/projects/lib. Sometime it helps to try echo command... first to see what file expansion does before running the command. Btw, your target directory name is unusual. Are you on native Ubuntu or is this WSL or else?

– xenoid
8 hours ago





The behavior you assumed is the actual one, both files should have been move to /u/projects/lib. Sometime it helps to try echo command... first to see what file expansion does before running the command. Btw, your target directory name is unusual. Are you on native Ubuntu or is this WSL or else?

– xenoid
8 hours ago










1 Answer
1






active

oldest

votes


















7















mv Command Deleted Files In Source Directory and Target Directory




-Impossible-. That is NOT how mv works.
- "mv" does a "cp -a" if it actually moves files (as in across filesystems) and only if it gets a confirmation the "cp -a" was successful it does a remove. See $ info mv for a detailed explanation on this.



Moving files within the same file system uses the rename call and that is just a metadata change. The file itself is not touched.




mv file_name* /u/projects/lib




"file_name*" was likely 1 file and "lib" did not exist. As a result you renamed "file_name*" to "lib" by omitting the "/" at the end of "/u/projects/lib".
If you had added the "/" the command would have shown an error that the directory "lib" did not exist. A file rename that does not cross file system boundaries is just a metadata change.



Had "file_name*" been 2 or more files you would get an error about moving files onto the same file. And had "lib" existed as a directory you'd find the files in "lib/"






share|improve this answer






















  • 1





    ah yes. :=) fell for that again

    – Rinzwind
    7 hours ago











  • @mook765 nope it will error out.

    – Rinzwind
    6 hours ago













Your Answer








StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "89"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);






Scott Gersbank is a new contributor. Be nice, and check out our Code of Conduct.









draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1162921%2fmv-command-deleted-files-in-source-directory-and-target-directory%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









7















mv Command Deleted Files In Source Directory and Target Directory




-Impossible-. That is NOT how mv works.
- "mv" does a "cp -a" if it actually moves files (as in across filesystems) and only if it gets a confirmation the "cp -a" was successful it does a remove. See $ info mv for a detailed explanation on this.



Moving files within the same file system uses the rename call and that is just a metadata change. The file itself is not touched.




mv file_name* /u/projects/lib




"file_name*" was likely 1 file and "lib" did not exist. As a result you renamed "file_name*" to "lib" by omitting the "/" at the end of "/u/projects/lib".
If you had added the "/" the command would have shown an error that the directory "lib" did not exist. A file rename that does not cross file system boundaries is just a metadata change.



Had "file_name*" been 2 or more files you would get an error about moving files onto the same file. And had "lib" existed as a directory you'd find the files in "lib/"






share|improve this answer






















  • 1





    ah yes. :=) fell for that again

    – Rinzwind
    7 hours ago











  • @mook765 nope it will error out.

    – Rinzwind
    6 hours ago















7















mv Command Deleted Files In Source Directory and Target Directory




-Impossible-. That is NOT how mv works.
- "mv" does a "cp -a" if it actually moves files (as in across filesystems) and only if it gets a confirmation the "cp -a" was successful it does a remove. See $ info mv for a detailed explanation on this.



Moving files within the same file system uses the rename call and that is just a metadata change. The file itself is not touched.




mv file_name* /u/projects/lib




"file_name*" was likely 1 file and "lib" did not exist. As a result you renamed "file_name*" to "lib" by omitting the "/" at the end of "/u/projects/lib".
If you had added the "/" the command would have shown an error that the directory "lib" did not exist. A file rename that does not cross file system boundaries is just a metadata change.



Had "file_name*" been 2 or more files you would get an error about moving files onto the same file. And had "lib" existed as a directory you'd find the files in "lib/"






share|improve this answer






















  • 1





    ah yes. :=) fell for that again

    – Rinzwind
    7 hours ago











  • @mook765 nope it will error out.

    – Rinzwind
    6 hours ago













7












7








7








mv Command Deleted Files In Source Directory and Target Directory




-Impossible-. That is NOT how mv works.
- "mv" does a "cp -a" if it actually moves files (as in across filesystems) and only if it gets a confirmation the "cp -a" was successful it does a remove. See $ info mv for a detailed explanation on this.



Moving files within the same file system uses the rename call and that is just a metadata change. The file itself is not touched.




mv file_name* /u/projects/lib




"file_name*" was likely 1 file and "lib" did not exist. As a result you renamed "file_name*" to "lib" by omitting the "/" at the end of "/u/projects/lib".
If you had added the "/" the command would have shown an error that the directory "lib" did not exist. A file rename that does not cross file system boundaries is just a metadata change.



Had "file_name*" been 2 or more files you would get an error about moving files onto the same file. And had "lib" existed as a directory you'd find the files in "lib/"






share|improve this answer
















mv Command Deleted Files In Source Directory and Target Directory




-Impossible-. That is NOT how mv works.
- "mv" does a "cp -a" if it actually moves files (as in across filesystems) and only if it gets a confirmation the "cp -a" was successful it does a remove. See $ info mv for a detailed explanation on this.



Moving files within the same file system uses the rename call and that is just a metadata change. The file itself is not touched.




mv file_name* /u/projects/lib




"file_name*" was likely 1 file and "lib" did not exist. As a result you renamed "file_name*" to "lib" by omitting the "/" at the end of "/u/projects/lib".
If you had added the "/" the command would have shown an error that the directory "lib" did not exist. A file rename that does not cross file system boundaries is just a metadata change.



Had "file_name*" been 2 or more files you would get an error about moving files onto the same file. And had "lib" existed as a directory you'd find the files in "lib/"







share|improve this answer














share|improve this answer



share|improve this answer








edited 7 hours ago

























answered 8 hours ago









RinzwindRinzwind

220k29 gold badges424 silver badges565 bronze badges




220k29 gold badges424 silver badges565 bronze badges










  • 1





    ah yes. :=) fell for that again

    – Rinzwind
    7 hours ago











  • @mook765 nope it will error out.

    – Rinzwind
    6 hours ago












  • 1





    ah yes. :=) fell for that again

    – Rinzwind
    7 hours ago











  • @mook765 nope it will error out.

    – Rinzwind
    6 hours ago







1




1





ah yes. :=) fell for that again

– Rinzwind
7 hours ago





ah yes. :=) fell for that again

– Rinzwind
7 hours ago













@mook765 nope it will error out.

– Rinzwind
6 hours ago





@mook765 nope it will error out.

– Rinzwind
6 hours ago










Scott Gersbank is a new contributor. Be nice, and check out our Code of Conduct.









draft saved

draft discarded


















Scott Gersbank is a new contributor. Be nice, and check out our Code of Conduct.












Scott Gersbank is a new contributor. Be nice, and check out our Code of Conduct.











Scott Gersbank is a new contributor. Be nice, and check out our Code of Conduct.














Thanks for contributing an answer to Ask Ubuntu!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1162921%2fmv-command-deleted-files-in-source-directory-and-target-directory%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Canceling a color specificationRandomly assigning color to Graphics3D objects?Default color for Filling in Mathematica 9Coloring specific elements of sets with a prime modified order in an array plotHow to pick a color differing significantly from the colors already in a given color list?Detection of the text colorColor numbers based on their valueCan color schemes for use with ColorData include opacity specification?My dynamic color schemes

Invision Community Contents History See also References External links Navigation menuProprietaryinvisioncommunity.comIPS Community ForumsIPS Community Forumsthis blog entry"License Changes, IP.Board 3.4, and the Future""Interview -- Matt Mecham of Ibforums""CEO Invision Power Board, Matt Mecham Is a Liar, Thief!"IPB License Explanation 1.3, 1.3.1, 2.0, and 2.1ArchivedSecurity Fixes, Updates And Enhancements For IPB 1.3.1Archived"New Demo Accounts - Invision Power Services"the original"New Default Skin"the original"Invision Power Board 3.0.0 and Applications Released"the original"Archived copy"the original"Perpetual licenses being done away with""Release Notes - Invision Power Services""Introducing: IPS Community Suite 4!"Invision Community Release Notes

François Viète Contents Biography Work and thought Bibliography See also Notes Further reading External links Navigation menup. 21Google Bookspp. 75–77Google BooksDe thou (from University of Saint Andrews)ArchivedGoogle BooksGoogle BooksGoogle BooksGoogle booksGoogle Bookscc-parthenay.frL'histoire universelle (fr)Universal History (en)ArchivedAdsabs.harvard.eduPagesperso-orange.frArchive.orgChikara Sasaki. Descartes' mathematical thought p.259Google BooksGoogle BooksGoogle Bookspp. 152 and onwardGoogle BooksGoogle BooksScribd.comGoogle Books1257-7979Google BooksGoogle BooksGoogle BooksGoogle BooksGoogle BooksGoogle BooksGallica.bnf.frGoogle BooksGoogle Books"François Viète"Francois Viète: Father of Modern Algebraic NotationThe Lawyer and the GamblerAbout TarporleySite de Jean-Paul GuichardL'algèbre nouvelle"About the Harmonicon"cb120511976(data)1188044800000 0001 0913 5903n82164680ola2013766880073431702w6vt1sb70287374827140948071409480