Linux command to move a directory into another directory

548 views Asked by At

I have a directory dir1 and it contains a lot of files and directories and also I have another directory dir2 and it is empty. And I need a linux command to move the dir1 with all the files and folders into dir2. The result should be like that dir2/dir1/...

I found the mv command, but it moves a file from a directory to another directory and I don't want that. Thank you!

2

There are 2 answers

1
Dhruv On BEST ANSWER

mv command can move directories also.

0
constqwerty On

Use cp with -r to copy content along with the folder recursively

 cp -r dir1 dir2/

Then remove the folder if u want (double check if u copied all the files LOL before removing)

 rm -r dir1