Results 1 to 4 of 4
Hello all!
I am fairly new to the Linux world, and in my linux class, I am working on a lab, using the Putty client...
I am in a directory ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
- 11-12-2012 #1Just Joined!
- Join Date
- Nov 2012
- Posts
- 2
Copying Single File Multiple Times into a Directory
Hello all!
I am fairly new to the Linux world, and in my linux class, I am working on a lab, using the Putty client...
I am in a directory called "week8" and here is the step I'm having issues with:
Step - Copy the file /bin/touch into this directory 3 times, each time giving the target a different name.
I have copied files into directories before using "cp," and have been successful. So when I type "cp /bin/touch week8" it looks like it copied, but when I use "ls" to search the directory, nothing shows up.
Am I missing something here?
If any more information is needed, please let me know. My "teacher" says this is a fairly easy task; that is all they said when I asked for assistance.
Thanks!!
- 11-13-2012 #2Trusted Penguin
- Join Date
- May 2011
- Posts
- 3,673
Hello and welcome!
First off, just so you know, homework questions are against Forum Rules. However, your question is fairly basic, so I think we can help you here.
So when you did the command "cp /bin/touch week8", did the directory "week8" already exist in the current working directory? You can confirm by just doing an "ls -l" command, while in the directory you think it is in. you should see the dir in the output, if it exists, e.g.:
Notice the "d" at the beginning of the permissions in the first column, that indicates that it is a directory.Code:# ls -l drwxrwxr-x 2 root root 4096 Nov 12 22:32 week8
To list the contents of a directory in your current working dir, you can put a "./" in front of the dir you are listing (e.g., "ls ./week8"). you can further add a "/" to the end of the dir name, to force ls to look only for dirs (so it would not list a file of the name "week8", confusing you). so putting it together, you could do:
you should then get the output of the directory "week8".Code:ls -l ./week8/
Going back to your problem, if you are already in a dir called "week8" and let us say that directory is in your home directory (i.e., /home/user/week8), and you wanted to copy something into the "week8" dir, then you'd just have to do:
the "." is the destination argument to cp and means "the current dir". you can always use the absolute path, too, even if you are in the dir, e.g.:Code:cp /some/file .
i always add the trailing slash to a dir (i.e., week8/) just in case i make a mistake and the destination dir does not actually exist. in that case, cp will give me an error (which is what i want).Code:cp /some/file /home/user/week8/
Hopefully this helps you a little.
- 11-13-2012 #3Just Joined!
- Join Date
- Nov 2012
- Posts
- 2
Thank you for the quick response! Yes, this definitely helps; it appears that my syntax was incorrect.
Thanks again!!
- 11-14-2012 #4Trusted Penguin
- Join Date
- May 2011
- Posts
- 3,673




