Linux allows you to easily work with files & directories. Sometimes you may need to merge folders & directories in Linux. In this article, we will learn how to merge folders & directories in Linux.
How to Merge Folders & Directories in Linux
Here are the steps to merge folders & directories in Linux. cp is one of the simplest commands to help you merge folders & directories in Linux.
Here is the syntax to copy multiple folders into a single one.
cp -rv /path/to/copy1 /path/to/copy2 /path/to/copy3 /dest/dir
For example, if you want to copy contents of folders /home/ubuntu/data1, /home/ubuntu/data2, /home/ubuntu/data3 into /home/ubuntu/projects then you can use the following command.
cp -rv /home/ubuntu/data1 /home/ubuntu/data2 /home/ubuntu/data3 /home/ubuntu/projects
Basically, you need to list all the folders that you want to combine one after the other in space-separated manner and mention the destination folder at the end of the command.
You can customize these commands as per your requirement.
How to Split Folder into Subfolders in Linux
How to Split Large File into Smaller Files in Linux
How to Sort Files into Folders in Linux
How to Add Newline After Pattern in Vim
How to Convert CRLF to LF in Linux