Copying Directories

Learn how to copy directories.

We'll cover the following

Simple copy

When we copy a directory, we’re duplicating its contents, including all files and subdirectories. Let’s demonstrate by making a backup of the code directory in our structure. Try copying files/code to files/backups/code:

mkdir -p files/{movies,music,photos,docs/{diagrams,markdown},code/{go,js,elm}}
touch files/docs/markdown/chapter{1..3}.md
mkdir files/backups
clear
cp files/code files/backups/code

Run these commands on the terminal below for practice.

Get hands-on with 1200+ tech skills courses.