1
Let's say you have this directory tree
parent
-----child1
-----file0
-----grandchild1
-----file1
-----file2
-----grandchild2
-----file3
-----child2
Now there are two things I need to learn how to do
- Copy the folder child1 into child2, so that there will be a parent/child2/child1/grancdhild1/file1
- Copy the contents of folder child1 to child2, so there will parent/child2/grancdhild1/file1
Notice the second one does not have a "child1", in the first one we are copying a folder into a new folder, in the second one we are copying the contents of a folder to another folder.
If it matters, lets say your current location is parent.
My main challenge here is to copy everything (sub directories, hidden files etc..)
1@Eroen is right - * doesn't match dot files. But there's another way to copy everything (including dot files!) from
child1
tochild2
. Just replace that * with a . (dot), as in:cp -r child1/. child2
– gerlos – 2017-09-20T22:11:46.6233Note that shell globbing (here, the '*') usually won't match anything starting with a period ('.'). – Eroen – 2011-12-13T08:58:06.257
1Stupid dotfiles. – Rob – 2011-12-14T15:57:15.440
So in linux, * marches directories (unlike MS DOS), but not hidden files correct? – user893730 – 2011-12-14T18:17:55.053
1It wouldn't be right to say "in linux" because "*" symbol expansion depends on specific shell. For specific details about "*" meaning in bash I must point you to bash documentation section "Pathname Extension", part about environmental variable "GLOBIGNORE" and description of "dotglob" option (they say a bit about "*" expanding to file names starting with dot). Be advised: other shells may behave differently in that matter. – thebodzio – 2011-12-14T23:26:03.550