🖥️

Bash Copy Commands and Wildcards

Jul 19, 2025

Overview

This lecture explains how to use copy commands and wildcards in Bash, including copying individual files, multiple files with patterns, and entire directories recursively.

Copying Files in Bash

  • The Bash shell allows copying files using a command similar to the Windows copy command.
  • To copy a single file (e.g., myverycoolfile.txt) to the desktop, use the copy command followed by the file name and destination.
  • Wildcards like the asterisk () can be used to match multiple files based on patterns (e.g., *.png).

Copying Multiple Files with Wildcards

  • To copy all PNG files in a directory, use the command with the pattern *.png followed by the destination path (e.g., the desktop).
  • This method selects all files ending with .png, like pizza.png, soda.png, and cake.png.*

Copying Directories Recursively

  • To copy an entire directory and its contents, use the recursive flag -R with the copy command.
  • For example, copying a folder named "cat pictures" to the desktop requires the recursive flag.

Key Terms & Definitions

  • Wildcard (*) — A symbol used to match multiple files based on their names or extensions.
  • Recursive copy (-R) — A flag used when copying directories to ensure all subfolders and files are included.

Action Items / Next Steps

  • Practice copying single files, multiple files (with wildcards), and entire directories in Bash.