How to copy or move all files and folders from linux shell
• • ☕️ 1 min readHow to copy all thee files and folders from a directory to another from the linux shell
First let’s create a 2 directories, each with files and directories inside them with the following set of bash commands:
mkdir dir1
mkdir dir2
#creating files inside each dir
touch dir1/y
touch dir2/y
#creating directories inside each dir
mkdir dir1/child_dir
mkdir dir2/child_dir
Trying the straightforward:
cp dir1 dir2
will not work.
what you need to use is the flag -r which means recursively.
to to copy all thee files and folders from a directory to another from the linux shell use the following:
cp -r dir1 dir2