0

I have this directory structure:

parent_folder/child_folder/

I want to copy the contents of the child folder to the parent folder, but I don't know how to do it with cp.

2

If you want to copy all content then run the command below

cp path-of-child-folder/* path-of-parent-folder

If particular content then run the command

cp path-of-child-folder/content path-of-parent-folder

0

You should use sudo command before the commands if you are copying files that are owned by ROOT or someone else.

To copy the all the files from the current folder to the parent folder, there are plenty of ways to do that.

. means current folder.
.. means parent folder of the current folder.
* means copy everything from the current folder (wildcard).
-R means copy folders and files in inside them recursively.

1) Easiest way to do this:

cd /path/to/child/directory
cp ./* ../ -R

2) By providing exact path:

cp /path/to/child/folder/* /path/to/parent/folder -R

If you are not sure what is your parent directory, and you are in the child directory, follow this command to get the path of the parent directory.

pwd

It means Print Working Directory.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.