Having doubts about cp command ? pls help

hi, my name is prashanth. currently taking LFCS course
i have a problem with cp command

bob@ubuntu-host ~ ➜ cp -r /home/bob/lfcs/ old-data-3

bob@ubuntu-host ~ ➜ ls old-data-3/
data1 data2 data3 lfcs.txt

bob@ubuntu-host ~ ➜ cp -r /home/bob/lfcs/ old-data-3

bob@ubuntu-host ~ ➜ ls old-data-3/
data1 data2 data3 lfcs lfcs.txt

i am trying to copy the “lfcs” folder into “old-data-3” folder
but it is copying only the contents of “lfcs” folder
when i run the same command for the second time it copies the “lfcs” folder in to “old-data-3”
can someone pls explain ?

Answered in discord (in one of the places you posted).
As mentioned in against your second discord posting - no need to scatter-post!

I think, the explanation “You need a trailing slash also on the target directory” in Discord is also not entirely accurate / complete.

The first cp -r /home/bob/lfcs/ old-data-3 would only create the target directory named old-data-3, in case it didin’t exist yet, and copy the contents of lcfs into it.
The second cp -r /home/bob/lfcs/ old-data-3 would copy the the entire lcfs directory into an already existing old-data-3 (created by the first cp command)

Normally, you don’t need a trailing slash on the target directory, because it doesn’t change the cp behavior in case the target directory doesn’t exist - it would be created anyway with a new name the first time you ran cp command.
But in most cases, it helps a lot to use Bash auto-completion feature to see, if Bash adds the trailing slash to a target name on its own:
a) if it does, the directory already exists, and the entire source will be copied into it
b) if it doesn’t, the directory doesn’t exist yet, and the source will be copied “in place” of a target directory (if there’s no other type of file already with such name)

user@hostname:/home/project$ ls
user@hostname:/home/project$ mkdir -p lcfs/data{1..3}/
user@hostname:/home/project$ touch lcfs/lcfs.txt
user@hostname:/home/project$ cp -r /home/project/lcfs/ old-data-3/
user@hostname:/home/project$ ls
lcfs  old-data-3
user@hostname:/home/project$ ls old-data-3/
data1  data2  data3  lcfs.txt
user@hostname:/home/project$ rm -rf old-data-3/
user@hostname:/home/project$ cp -r /home/project/lcfs/ old-data-3 
user@hostname:/home/project$ ls old-data-3/
data1  data2  data3  lcfs.txt
user@hostname:/home/project$ rm -rf old-data-3/
user@hostname:/home/project$ mkdir old-data-3
user@hostname:/home/project$ cp -r /home/project/lcfs/ old-data-3
user@hostname:/home/project$ ls old-data-3/
lcfs
user@hostname:/home/project$ rm -rf old-data-3/
user@hostname:/home/project$ mkdir old-data-3
user@hostname:/home/project$ cp -r /home/project/lcfs/ old-data-3/
user@hostname:/home/project$ ls old-data-3/
lcfs
user@hostname:/home/project$ 

Note, that it doesn’t actually matter, whether you add a trailing slash to the source as well, but it should also help when it’s auto-completed by a shell.