Beneath is from man cp
.
NAME
cp – copy information
SYNOPSIS
cp [-R [-H | -L | -P]] [-fi | -n] [-alpsvXx] source_file
target_file
cp [-R [-H | -L | -P]] [-fi | -n] [-alpsvXx]
source_file
...
target_directory
DESCRIPTION
Within the first synopsis type, the cp utility copies the contents of the
source_file
to the target_file
. Within the second synopsis type, the contents
of every named source_file
is copied to the vacation spot target_directory
.
The names of the information themselves usually are not modified. If cp detects an
try to repeat a file to itself, the copy will fail.
The OP’s query pertains to which of the 2 varieties given above is getting used. This depends upon whether or not the goal listing exists. The second type requires the goal listing to exist. When getting into the next instructions from the OP’s query, the second type is used.
cp -Rip dir1 dir2/
cp -Rip dir1/ dir2/
When getting into the next instructions from the OP’s query, the primary type is used.
cp -Rip dir1 dir1-copy/
cp -Rip dir1/ dir1-copy/
With each the earlier two instructions, the outcomes are the identical. Listing dir1
is duplicated, the place dir1-copy
is the title of the duplicate. The usage of the /
after dir1
is redundant.
One can show the primary type is being utilized by including an current file to both command. For instance, say there exists a file named hello.txt
and that the next command is entered. Since there are actually two supply information, the second type should be used.
cp -Rip dir1 hello.txt dir1-copy/
The consequence would be the following error message.
cp: dir1-copy shouldn't be a listing
Since neither of the instructions beneath produce an error message, the primary type should have been used.
cp -Rip dir1 dir1-copy/
cp -Rip dir1/ dir1-copy/
As for the OP’s “intently associated query”
The man cp
output makes the next distinction involving using the /
character after a listing title when the -R
choice is specified.
-R If source_file
designates a listing, cp copies the listing and
the whole subtree linked at that time. If the source_file
ends
in a /
, the contents of the listing are copied reasonably than the
listing itself….
No such distinctions are made within the output from man mv
. With the mv
command, the trailing /
has no particular which means.