Skip to main content
LESSON 3 of 5//File Operations

Copying with cp

The cp command copies files and directories. For directories, you need the -r (recursive) flag to copy everything inside them.

Copying files and directorieszsh // interactive
~cp index.html index-backup.html
# Copy a directory recursively
~cp -r src/ src-backup/
# Copy with verbose output
~cp -rv src/ dist/
src/index.ts -> dist/index.ts
src/app.tsx -> dist/app.tsx
!

Overwrite risk

By default, cp overwrites existing files without asking. Use cp -i to get a confirmation prompt before overwriting.

PRACTICE//Try the commands from this lesson
INTERACTIVE_TERMINAL//sandbox
Practice terminal — try the commands from this lesson!
Type 'help' for available commands. Tab completion not available in simulator.
Try: