In order to copy a directory entirely from one location to another in Linux/Unix/Mac/Bash you can make use of the below command,
Syntax:cp -r source-dir destination-directory-location
cp : This is the copy utility used to copy file or files from source to a target file/files.
-r : This option is used if the source is a directory, when used with cp - it copies the directory and the entire subtree of the directory to the destination, note this will also copy the symbolic links.
source-dir: location of the source directory. Note that it should be a directory.
destination-directory-location: the target location where the directory (folder) needs to be copied.
Let's say I have a directory myApp on my Desktop location and I want to copy it to /Documents
cp -r myApp /Users/code2care/Documents
Note that if you do not provide -r parameter you will get an error saying cannot copy as the source is a directory.
code2care@mac Desktop % cp myApp /Users/code2care/Documents
cp: myApp is a directory (not copied).
All the files and subfolders will get copied!
- Command to know the Available Memory on Linux System
- How to install curl on Alpine Linux
- How to backup a file in Linux/Unix
- Install Java Runtime Environment (Oracle or open JRE) on Ubuntu
- What is the Default Admin user and Password for Jenkins
- How to tar.gz a directory or folder Command
- Copy entire directory using Terminal Command [Linux, Mac, Bash]
- Fix: bash: ipconfig: command not found on Linux
- Command to check Last Login or Reboot History of Users and TTYs
- Linux: Create a New User and Password and Login Example
- ls command to list only directories
- bash: cls: command not found
- How to exit from nano command
- Installing and using unzip Command to unzip a zip file using Terminal
- What does apt-get update command does?
- ls command: sort files by name alphabetically A-Z or Z-A [Linux/Unix/macOS/Bash]
- How to remove or uninstall Java from Ubuntu using apt-get
- scp: ssh: connect to host xxxx port 22: Connection refused Error
- Sort ls command by last modified date and time
- Create Nested Directories using mkdir Command
- How to Exit a File in Terminal (Bash/Zsh)
- Command to know the installed Debian version?
- How to connect to SSH port other than default 22
- How to save a file in Nano Editor and Exit
- Install OpenSSL on Linux/Ubuntu
- Fix Power BI error Access to the resource is forbidden when connecting SharePoint Online List as data source - SharePoint
- How to reset Eclipse IDE Code Font - Eclipse
- Java 8 Supplier Functional Interface Examples - Java
- Fix: error: non-static type variable T cannot be referenced from a static context - Java
- How to turn off Stage Manager - macOS Ventura - MacOS
- 🎃 Halloween Hashtag 2022 on Social Media 🎃 - Hashtags
- 25: How to rename a file using Python Program - Python-Programs
- Java Stream Word Count Example - Java