Skip to content

Instantly share code, notes, and snippets.

@ostechnix
Created July 11, 2024 11:03
Show Gist options
  • Save ostechnix/999fb1dbc1ec65c1566a3f1e4c396108 to your computer and use it in GitHub Desktop.
Save ostechnix/999fb1dbc1ec65c1566a3f1e4c396108 to your computer and use it in GitHub Desktop.
Filecp - A Simple Bash Script to Copy Files from One Location to Another
#!/usr/bin/env bash
# ------------------------------------------------------------------
# Script Name: filecp.sh
# Description: A Bash Script to Copy Files
# Website: https://gist.github.com/ostechnix
# Version: 1.0
# Usage: sudo ./filecp.sh
# ------------------------------------------------------------------
SOURCE_DIR=/path/to/source/directory
DEST_DIR=/path/to/destination/directory
echo "This script will copy all files from $SOURCE_DIR to $DEST_DIR."
echo "If files with the same names already exist in $DEST_DIR, they will be overwritten."
echo "Are you sure you want to proceed?"
echo "Enter 'y' to continue, 'n' to cancel, or 'c' to cancel and exit the script:"
read -r response
case $response in
[yY])
echo "Copying files from $SOURCE_DIR to $DEST_DIR..."
cp -r $SOURCE_DIR/* $DEST_DIR/
;;
[nN])
echo "Operation cancelled. No files will be copied."
;;
[cC])
echo "Exiting the script."
exit 0
;;
*)
echo "Invalid input. Please enter 'y', 'n', or 'c'."
;;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment