1

Case 1: If dst does not exist, then cp -vr src dst creates dst and copies all the content from src to dst:

$ cp -vr src dst
'src' -> 'dst'
'src/t0.c' -> 'dst/t0.c'

Case 2: If dst does exist, then cp -vr src dst creates dst/src and copies all the content from src to dst/src:

$ cp -vr src dst
'src' -> 'dst/src'
'src/t0.c' -> 'dst/src/t0.c'

Question: For case 1: is there any option that will make cp trigger No such file or directory error instead of creating dst?

2

1 Answer 1

3

With the cp of GNU coreutils:

cp -rt dst src/.

Notice the reverse order of the arguments -- in fact, dst is an argument of the -t, --target-directory option.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .