Created
November 14, 2024 16:52
-
-
Save hiranp/68ee794b34880ea5760ab3c9ad3a9cf6 to your computer and use it in GitHub Desktop.
Revisions
-
hiranp revised this gist
Nov 14, 2024 . 1 changed file with 18 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1 +1,18 @@ #!/bin/bash # Define source and destination directories SOURCE_DIR="/path/to/source" DEST_DIR="/path/to/destination" START_DATE="2024-10-01" # Change this to the start date of the range END_DATE="2024-10-15" # Change this to the end date of the range EXTENSIONS=("*.txt" "*.log" "*.conf") # Add the specific extensions you want to match # Ensure the destination directory exists mkdir -p "$DEST_DIR" # Find and copy files with specific extensions and within the date range from SOURCE_DIR to DEST_DIR for EXT in "${EXTENSIONS[@]}"; do find "$SOURCE_DIR" -type f -name "$EXT" -newermt "$START_DATE" ! -newermt "$END_DATE +1 day" -exec cp --parents {} "$DEST_DIR" \; done echo "Files with specific extensions and within the date range have been copied from $SOURCE_DIR to $DEST_DIR." -
hiranp created this gist
Nov 14, 2024 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1 @@