📁

Bash File Copying Commands Overview

Jun 2, 2025

Bash File Copying Commands

Introduction

  • Bash can execute similar file copying commands as in Windows.
  • Useful for transferring files from one directory to another, like from a working directory to the desktop.

Copying Files

  • Basic Command: Use the cp command in bash for copying files, similar to Windows.
  • Example: To copy myverycoolfile.txt to the desktop, use: cp myverycoolfile.txt ~/Desktop

Using Wildcards

  • Asterisk Wildcard: Use * to select files with specific patterns.
  • Example: To copy all .png files to the desktop: cp *.png ~/Desktop
  • Applicable for files like pizza.png, soda.png, cake.png.

Copying Directories

  • Recursive Copy: Required to copy entire directories with contents.
  • Flag: Use -R with cp to copy directories.
  • Example: To copy a directory named cat_pictures to the desktop: cp -R cat_pictures ~/Desktop

Summary

  • Bash supports file and directory copying similar to Windows with the cp command.
  • Wildcards and recursive options are available for flexible file management.
  • This makes bash a versatile tool for handling file operations across different environments.