Jump to content

cp command [solved]


Recommended Posts

OK, I am just starting with Linux so please bear with me and be patient. I am going though some beginner guides and HowTo for using Linux.

I have created a directory "Correspondance" and another one called "rubbish". In the correspondance one I have an OpenOffice.writer file that I want to copy to the rubbish directory using the shell.

So I enter the following command:

cp myletter rubbish

When I go to the rubbish directory there is nothing there. And under correspondance there is now something called rubish (but it is not a directory. What am I doing wrong?

Thanks

JC

Link to comment
Share on other sites

JC,

 

From Section 4.6 of the Rute found at http://rute.2038bug.com/index.html.gz

 

4.6 Relative vs. Absolute Pathnames

 

Commands can be given file name arguments in two ways. If you are in the same directory as the file (i.e., the file is in the current directory), then you can just enter the file name on its own (e.g., cp my_file new_file). Otherwise, you can enter the full path name, like cp /home/jack/my_file /home/jack/new_file. Very often administrators use the notation ./my_file to be clear about the distinction, for instance, cp ./my_file ./new_file. The leading ./ makes it clear that both files are relative to the current directory. File names not starting with a / are called relative path names, and otherwise, absolute path names.

 

Your cp command placed a copy of the file myletter called rubbish in the same directory vs. making a copy of the file myletter called myletter in the rubbish folder as desired. Your description of your problem did not specify the exact location of the new rubbish directory so a specific answer can not be given and be 100% acurate, but if your rubbish directory is in the same directory that your Correspondance directory is in then Paul's recommendation above should work.

 

Read the Rute at the above mentioned site from beginning to end and you will have a better understanding.

 

Cheers,

-Bill

Link to comment
Share on other sites

Bill thanks for your post. The rute link looks pretty good and i will study that. I found the move from XP to Linux pretty difficult to be honest. But at the same time very interesting. I was confused with the cp command because I was following a tutorial and obviously it was not working. My Correspondance and Rubbish directories are under the same directory. I guess it is like anything else by just doing over and over I will get better.

JC

Link to comment
Share on other sites

I wasn't sure of your directory structure, whether rubbish was inside correspondance, or whether it was at the same level. I've followed using Paul's command, and here is the items I've typed. It doesn't leave me a rubbish item in correspondance, but only the original folder I created there:

 

mkdir correspondance
[ian@europa ~]$ cd correspondance/
[ian@europa correspondance]$ vi myletter
[ian@europa correspondance]$ ls
myletter
[ian@europa correspondance]$ mkdir rubbish
[ian@europa correspondance]$ cp myletter ../rubbish/
cp: cannot create regular file `../rubbish/myletter': No such file or directory
[ian@europa correspondance]$ cp myletter rubbish/
[ian@europa correspondance]$ ls rubbish
myletter
[ian@europa correspondance]$ cd ..
[ian@europa ~]$ mkdir rubbish
[ian@europa ~]$ cd correspondance/
[ian@europa correspondance]$ cp myletter ../rubbish/
[ian@europa correspondance]$ ls ../rubbish
myletter

Link to comment
Share on other sites

Yes you are right ianw1974, I don't know what I did but I have must have done something wrong in the first place.

Did you guys found the move (if any) from Windows very difficult or not, to be honest I am struggling with it, but nevertheless enjoying it as well and happy to use my brain a bit more instead of just clicking on some buttons.

TheNovice

Link to comment
Share on other sites

The first time when I tried Mandrake 7.x I used it for a day or two, and was back to Windows. I didn't have the time to learn it.

 

Now, I was kind of forced to, to get a new job which was mostly Linux based. So I spent six months learning and playing and then I started working, which meant I learnt even more quickly!

 

Sometimes, yes can be tricky. Find myself more in Linux now than Windows :P

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...