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!
- Rename a directory using Linux/Unix command
- ls command to list only directories
- How to Restart or Reload Nginx Server Service on Linux
- 3 ways to clear screen on Linux Terminal
- ls command: sort files by name alphabetically A-Z or Z-A [Linux/Unix/macOS/Bash]
- Copy entire directory using Terminal Command [Linux, Mac, Bash]
- Fix: sudo: unable to open Read-only file system
- Create Hidden File or Directory using Shell Command
- Command to know the installed Debian version?
- The Date Command and its usage [Linux - Unix - macOS]
- Fix - bash: man: command not found
- How to tar.gz a directory or folder Command
- How to Display content of a file in Terminal Screen?
- How to change bash terminal prompt string and color
- Sort ls command by last modified date and time
- Execute .bin and .run file Ubuntu Linux
- zsh hello world example
- How to check uptime of Linux/Unix/macOS system/server using console command?
- [Fix] Linux - bash: useradd: command not found
- Command to check Last Login or Reboot History of Users and TTYs
- How to install and Configure sar sysstat tools in Ubuntu Linux
- How to use SCP Command to Copy Directory
- Linux Remove or Delete Files and Directories using Terminal Commands
- How to connect to SSH port other than default 22
- Install OpenSSL on Linux/Ubuntu
- Installing MongoDB on Linux/Unix/macOS/Ubuntu - MacOS
- How to remove or unstage a file from git staged area - Git
- How to Recover Deleted Messages on iPhone - iOS
- Fix: Jupyter Notebook Black Web Page on Localhost - Python
- Linux Remove or Delete Files and Directories using Terminal Commands - Linux
- Android : Unable to load VM from snapshot : Mac OS X Error - Android
- How to Clear Gradle Cache on Mac - Gradle
- Java + Spring JDBC Template + Gradle Example - Java