Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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.
If you are copying file , in source you have to give the path(Absolute/relative) of file.
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.
Last edited by divyashree; 07-04-2011 at 11:26 PM.
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
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....!!!
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.
but why would anyone not edit the file and use cp command to copy a file into another...?
Well, I think the OP is trying to learn some basic commands, but is getting confused with the order of parameters when using cp. He/she mentions in his/her first post that the idea is to create a directory (even though it says "file", I'm sure "directory" was meant), and copy two files into that directory.
Unfortunately, the man page is not helping him/her, so let's hope the tutorial link you posted will be useful for the OP.
Well, I think the OP is trying to learn some basic commands, but is getting confused with the order of parameters when using cp. He/she mentions in his/her first post that the idea is to create a directory (even though it says "file", I'm sure "directory" was meant), and copy two files into that directory.
Unfortunately, the man page is not helping him/her, so let's hope the tutorial link you posted will be useful for the OP.
yeah,exactly that is what came to my mind too.
But now he/she is sorted
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.