-5

I have this problem as part of a school assignment:

screenshot

NOTE: In case it's hard to read in the image above, here's the directory tree:

$ tree . `-- sample_dir1 `-- sample_dir |-- admin |-- cambridge | |-- cafeteria | |-- library | `-- security | |-- annex | |-- building | `-- parking |-- faculty |-- history.exe |-- markham | |-- annex | |-- building1 | `-- parking |-- oxford | |-- outline.doc | |-- programming | | `-- report.pdf | `-- security `-- stenton |-- gen_ed `-- lib_arts |-- english.txt `-- match.doc 15 directories, 11 files 

I tried doing the command:

$ cp ../cambridge/security/parking ./parking2 

...but it isn't working. The question in the image above states that the current directory is stenton, and that we need to make a copy of the file named parking (from the security directory), and to name the new file parking2, and place it in the current directory, stenton, using relative pathnames.

What am I doing wrong? My cp command seems to be correct.

4
  • yes an assignment ^^ stuck on this questions for 1 day now Commented Oct 15, 2014 at 20:46
  • man7.org/linux/man-pages/man1/cp.1.html Commented Oct 15, 2014 at 20:47
  • 2
    @user88022 Sorry for the rough introduction you got here. Not knowing about embedding images is understandable for a new user, but you should explain what you've tried (and how it failed) when asking for help. Commented Oct 15, 2014 at 23:43
  • 4
    This is ULI101 at Seneca College, which we get year after year. All assignments "MUST consist of the student’s OWN work". Commented Oct 22, 2016 at 1:52

2 Answers 2

8

The problem you're running into seems to be with your homework program.

From your comment on the other answer, you tried:

cp ../cambridge/security/parking ./parking2 

This is a perfectly valid command in a normal shell. However the issue is likely that your testing program doesn't want the ./ on the ./parking2.

When specifying the path to a file (with virtually any program, not just cp), if there is no leading / on the path, it implicitly becomes ./. So you should be good if you change your command to:

cp ../cambridge/security/parking parking2 
0

This is a very elementary question. I would read up on the man pages for this one. But nonetheless, here is your answer:

cp <SOURCE> . 

For example:

I have a file in this directory: /home/rkah/sample1 The file is called: sample

Say if I wanted to go to my home directory which is: /home/rkah/ and copy sample to /home/rkah/, I would run this command:

cp ~/sample/sample . The . symbol stands for present working directory or the directory im currently in.

11
  • 1
    ive tried that cp ../cambridge/security/parking ./parking2 it doesnt work Commented Oct 15, 2014 at 20:49
  • 3
    @user88022 that command should work, but your software testing you may be sensitive to ./parking2 since a relative path isn't required to reference the current directory. Commented Oct 15, 2014 at 20:53
  • 3
    @user88022 because not specifying a directory means to use the current directory. It is implicit. Commented Oct 15, 2014 at 20:56
  • 3
    @ryekayo he had to copy a file from location1 to location2 with a new name, his first command was right, but he is not in a real shell but a testing software that wants a very specific answer and did not need the ./ to reference the current directory for his destination filename. Commented Oct 15, 2014 at 20:57
  • 3
    @ryekayo its ok, but realize that his first command you claim is wrong is completely valid for what he wants to do if he were in a real shell. You misread the question (reading the title and not the actual problem within the image he posted). Commented Oct 15, 2014 at 20:59

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.