terminal "cp" problem
I made a file in terminal "mkedir test", I want to copy 2 text files in it in it. So I do "cp /home/hunti/Desktop test.txt test/test2.txt" and it says "no such file or directory. I also try'd "cp /home/hunti/Desktop/test test/test2.txt" and it says "omitting directory", but nothing happens.
Any advice?? thanks |
You have a couple of mistakes there, first it's mkdir, not mkedir. Second, you give cp the files first and the directory last:
Code:
$cp test.txt test/test2.txt /home/hunti/Desktop |
There are two arguments which cp take:
Code:
cp <source> <destinetion> If you are copying directory use -r option with cp and the source is the path(Absolute/relative) to dir. And the destination is directory always , but while renaming a file destination is a file name. |
Thanks for reply. Funny enough
Code:
hunti@hunti-Aspire-M7720:~/Desktop$ cp -r test test/test2.txt When I do without -r Code:
hunti@hunti-Aspire-M7720:~/Desktop$ cp test test/test2.txt ps: I try's cp man page and nothing was there that helped me. |
Quote:
I told you before destination is always a directory.. In your case destination is a file.. Try to understand 1st how it works.. |
Quote:
Code:
SYNOPSIS |
Quote:
how can you copy a file to another file ? just edit the file to add relevant items.... it is no big deal to understand that things can be copied into a directory only,but all you are trying is to copy a file into another...which i don't think is possible ! using cp command,destination has to be a directory always....!!! |
if you want help with cp command,then try this......
i'd advice first work out how a command works,then things go a lot more easier.. good luck ! |
Quote:
|
Quote:
|
thanks for reply's. I find another way that worked.
Code:
touch /home/hunti/Desktop/test test/test2.txt |
@ Reply
Hi huNti,
Welcome to LQ!!! I would like to point that mkdir is used to create directory and not file. Are you sure you have created a file in the first step. Here are the steps that you can try to perform the test: 1. cd /home/hunti (You are getting into your home directory, you will be there by default if you are logged in as the user hunti) 2. mkdir test1 (creating a test folder test1) 3. cd test1 (getting in the directory test1) 4. touch test1.txt (creating a blank file with the name test1.txt under /home/hunti/test1 ) 5. cd .. (getting back to previous directory that is /home/hunti) 6. mkdir test2 (creating another test folder test2, this is the folder where you will copy the file test1.txt) 7. cp /home/hunti/test1/test1.txt /home/hunti/test2 (command to copy over the file) I am using the full path in the command to avoid confusion. There are many switches you can use with cp command but here we are only copying one file so no switches are required. I hope this helps. |
Quote:
Unfortunately, the man page is not helping him/her, so let's hope the tutorial link you posted will be useful for the OP. |
Quote:
It is one option which is available to the user . It depends on user how he will achieve. |
Quote:
yeah,exactly that is what came to my mind too. But now he/she is sorted |
All times are GMT -5. The time now is 05:08 PM. |