Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions episodes/03-create.md
Original file line number Diff line number Diff line change
Expand Up @@ -697,8 +697,10 @@ or sets of characters when navigating the Unix file system.

For this exercise, you can test the commands in the `shell-lesson-data/exercise-data` directory.

We have seen how `cp` behaves when given two arguments,
but `cp` behaves differently when given three or more arguments.
We have seen how `cp` behaves when given two arguments. The second argument can
be a filename (what to name the copy) or an existing directory (where to put the copy).

`cp` behaves slightly differently when given three or more arguments.
Let's try giving `cp` three arguments.
In the example below, what does `cp` do when given several filenames and a directory name?

Expand Down Expand Up @@ -726,11 +728,12 @@ $ cp minotaur.dat unicorn.dat basilisk.dat

## Solution

When `cp` is given two arguments and the second is a destination directory
`cp` copies the files to the destination directory.
Comment on lines -729 to -730
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is helpful to distinguish between two and three arguments because for two arguments, if the second argument is not a directory but a filename, then the first file is copied and renamed.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok. Current text does not do this, but I agree it would be good to add. Maybe even in the main text rather than nested inside a challenge and solution.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Having it in the main text is a good idea.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps move this out of the challenge block and make it something that is demonstrated.

When `cp` is given three or more arguments,
the last argument must be a directory.
`cp` copies the other files specified
into that directory. If the last argument
is a file name, you get an error:

If given three or more arguments, `cp` throws an error such as the one below,
because it is expecting a destination directory name as the last argument.

```error
cp: target 'basilisk.dat' is not a directory
Expand Down