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!
- How to remove/delete a directory in Linux/macOs
- What does apt-get update command does?
- How to quit or exit SFTP Prompt on Terminal
- How to exit from nano command
- Rename a directory using Linux/Unix command
- Calculate days between dates using dateutils ddiff command
- 3 Commands to stop Nginx Server
- How to use SCP Command to Copy Directory
- bash: cls: command not found
- How to Install CVS Version Control on Linux/Ubuntu
- Copy entire directory using Terminal Command [Linux, Mac, Bash]
- [Ubuntu] Search a package and versions using apt command
- zsh hello world example
- SCP Copy all files from directory to Local Folder
- Create Hidden File or Directory using Shell Command
- Check SSH/OpenSSH version Command
- How to install python pip on Ubuntu using apt command
- How to remove or uninstall Java from Ubuntu using apt-get
- How to change bash terminal prompt string and color
- scp: ssh: connect to host xxxx port 22: Connection refused Error
- ls command sort by file size [Linix/UNIX/macOS/bash]
- Install Java Runtime Environment (Oracle or open JRE) on Ubuntu
- How to tar.gz a directory/folder
- Terminal display next month Calendar
- 3 ways to clear screen on Linux Terminal
- appcompat_v7 errors after updates to API level 21 Material Theme - Android
- How to enable Do Not Disturb (DND) mode in Microsoft Teams - Teams
- Multiline EditText in Android Example - Android
- How to remove app from Dock when closed [macOS Big Sur] - MacOS
- How to make macOS Terminal window Transparent (or Opaque) - MacOS
- That did'nt work, Issue type User not in directory - SharePoint external access error - SharePoint
- Check Wifi Connection static Android Programming - Android
- Convert text to random case using Notepad++ - NotepadPlusPlus