In this article, we will see how to copy folder with files to another folder in Linux.
We can do this by using Linux cp command with -R option. Following the syntax to copy folder with files to another folder in Linux:
cp -R path_to_source path_to_destination/
Following is the syntax to copy everything including symlinks and hidden files of folder to another directory :
cp -a path_to_source/. path_to_destination/
Examples:
1. Lets copy sscripting directory with files to another directory ‘newscripts’.
cp -r sscripting/ newscripts/
2. If we want to copy only files of directory to another in Linux use the following command.
cp -r sscripting/* scriptsfiles/
3. Lets copy sscripting directory files to another directory which is not present.
cp -R sscripting/ scriptdirectory/