The trailing slash is just following cp’s own special treatment
# beforedir/
file1
target/
orig.txt
# no trailing slash - copy *dir* to targetcp -r /path/to/some/dir /my/target
# after
target/
orig.txt
dir/ # dir copied to target
file1
# with trailing slash - copy *contents* of dir to targetcp -r /path/to/some/dir/ /my/target
# after
target/
orig.txt
file1 # contents of dir
The trailing slash is just following cp’s own special treatment
# before dir/ file1 target/ orig.txt # no trailing slash - copy *dir* to target cp -r /path/to/some/dir /my/target # after target/ orig.txt dir/ # dir copied to target file1 # with trailing slash - copy *contents* of dir to target cp -r /path/to/some/dir/ /my/target # after target/ orig.txt file1 # contents of dir