Creates copies of files and directories.
⚠️ Default behavior is to overwrite destination files.
Copy single file
cp ~/.bashrc ~/.bashrc-copy
Copy multiple files into a new directory
cd ~ && cp .bashrc .zshrc target-dir cd ~ && cp -t target-dir .bashrc .zshrc
target-dirdirectory and copy
Copy by wildcard selection
cd ~ && cp -t target-dir *.zip *.txt
Copy a directory
cp -r ~/.config ~/.config-copy
Update only newer files
cp -ru ~/.config ~/.config-last-backup
This just copies files that modified after the last copy.
Create backup for existing destination files
cp -rb ~/.config ~/.config-last-backup
Set to ask for overwriting
cp -ri ~/.config ~/.config-last-backup
Set to keep existing files (no overwrite)
cp -rn ~/.config ~/.config-last-backup
About Living in the Shell
Obsessed with doing things in the shell, I’ve decided to share my daily struggles on living in the shell as terse but informative posts.