Exercise 8/10 mv command

<PLEASE USE THE FOLLOWING TEMPLATE TO HELP YOU CREATE A GREAT POST!>

<Below this line, add a link to the EXACT exercise that you are asking about.>
https://www.codecademy.com/courses/learn-the-command-line/lessons/manipulation/exercises/mv?action=lesson_resume
<Below this line, describe in what way does your code behave incorrectly? Include ALL error messages.>
When moving batman.txt into spiderman.txt it renames batman.txt to spiderman.txt, where does the data in each file go?

<Below this line, add a screenshot of your whole web browser so that we can see what you see.>

There are two possible scenarios, where one file exists and you want to rename it, and when both exist and you want to overwrite one with the other.

In the first scenario, by ‘moving’ one file to another, as yet non-existent file, you just change the name of your file. All the file contents remain untouched.

In the second, more complex scenario the first file’s contents stay the same, but the name of the file changes. The other file that used to have that name ceases to exist.

You can test this yourself. Create 2 files in the same directory, batman.txt and spiderman.txt. Put a quote in each file to identify them such as:

batman.txt:
Where’s Rachel?!

spiderman.txt:
With great power comes great responsibility.

Now in your command shell type $ mv batman.txt spiderman.txt. Then do an $ ls. You’ll see that there no longer is a batman.txt file, just a spiderman.txt. If you open spiderman.txt you’ll find the batman quote.

1 Like

Thank you. That was a perfect explanation.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.