0

I think I must be missing something obvious. I am in a directory called AmHist, with 2 subdirectories, Assign and Resources. I want to move 2 files from Assign to Resources.

I try

cp LinuxHist Linuxnotes.txt Resources

but for both files I get No such file or directory. If I do

cp Assign/LinuxHist Linuxnotes.txt Resources

it only copies LinuxHist and I get the error again for Linuxnotes.txt on how it doesn't exist. I am very new to linux, so am I missing something basic about relative and absolute paths? I know the basics of Windows command line, so it's not completely alien, but I think I must be missing something big

4

You need to specify the directory name for both source files:

cp Assign/LinuxHist Assign/Linuxnotes.txt Resources

(There are many more ways of writing this, but this is the simplest form of the command to understand).

Now your title has "Copy" but the question says "move". The cp command will copy. If, instead you want to move the file then use the mv command:

mv Assign/LinuxHist Assign/Linuxnotes.txt Resources
  • Is it possible to move or copy files while I am in the Assign subdirectory to the Resources subdirectory? – user2120893 Jul 22 '16 at 20:16
  • Yes, in a similar way that you would with Windows; .. means up a level. So cp LinuxHist Linuxnotes.txt ../Resources – Stephen Harris Jul 22 '16 at 20:17
  • Ok, thank you! It's hard to wrap my mind around this way of dealing with directories, being so used to windows – user2120893 Jul 22 '16 at 20:18
  • There are differences, but the only ones for what you are doing here are names of commands and / instead of \ . Note a better syntax is cp -t ../Resources LinuxHist Linuxnotes.txt now the first is the special/destination, and there are no odd behaviour issues for when the target does not exist. Read man mv/man cp and always use option -t or -T (this applies the same for mv, cp, ln). – ctrl-alt-delor Jul 22 '16 at 23:58
0

You can go to first your source directory i.e assign by using cd command. After that, you can use this:

mv LinuxHist Linuxnotes.txt ../Resources

This will definitely work.

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.