0

I have 2 folder:
- /Desktop/old
- /Desktop/new

In old folder, I have following file:
- olda.txt
- oldb.txt

In new folder, I have following file:
- newa.txt
- newb.txt
- newc.txt

And I want to overwrite the file from old to new. And I tried like this:

 mv /home/user/Desktop/old /home/user/Desktop/new

I get the below output in new folder:
- old
- newa.txt
- newb.txt
- newc.txt

What I want is like this:
- olda.txt (from old/olda.txt)
- oldb.txt (from old/oldb.txt)
- newc.txt

How should I write in order to get it?

  • Your requirement is a bit weird. Can you specify it further? For example, we are told that new/newa.txt should be renamed to old/olda.txt, but what about new/olda.txt, or new/some_other_filename? – Celada Sep 1 '15 at 6:53
0

You just moved the folder itself inside the new folder. Just use:

mv /home/user/Desktop/old/* /home/user/Desktop/new
  • The OP wants to rename files in addition to moving them. For example, new/newa.txt has to become old/olda.txt. – Celada Sep 1 '15 at 6:54
  • Downvoted! OP Wants to overwrite the newa.txt and newb.txt with olda.txt and oldb.txt. – Thushi Sep 1 '15 at 6:55
  • @WitchDoctor I misunderstood, but according to the comments: Why do you know that the OP wants to rename the files? – chaos Sep 1 '15 at 6:57
  • @chaos You solved my problems. – Michael Kuan Sep 1 '15 at 7:01
  • @WitchDoctor Also, your comment suggests exactly the same... =) – chaos Sep 1 '15 at 7:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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