« Back to Index

Copying Files and Directories

View original Gist on GitHub

Tags: #shell

1. README.md

A trailing slash == copy all files
No trailing slash == copy the directory

Caution with Bash when copying Files and Directories.bash

# copy src directory into the destination directory
# i.e. you'll end up with compute/src/...
cp -r src ~/Code/rust/compute/

# copy the 'files' from the src directory into the destination directory
# i.e. you'll end up with compute/...
#
# NOTICE the subtle difference! a trailing slash on src/ will 
# copy the files within that directory rather than the directory as a whole.
cp -r src/ ~/Code/rust/compute/