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.
Also read:
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
Related posts:
How to Give User Access to Folder in Linux
How to Change Shutdown Message in Linux
How to Save Terminal History in Linux
XARGS Command To Find & Delete Files
How to Share Linux Terminal Session With Others
How to Kill Unresponsive Process in Linux
How to Capture Top Command Output to File
How to Secure SSH Server on your System

Sreeram has more than 10 years of experience in web development, Python, Linux, SQL and database programming.