Skip to content

Instantly share code, notes, and snippets.

@thiagomgo
Created August 2, 2019 14:02
Show Gist options
  • Save thiagomgo/46cefd4215cd4d827cedb0a74c1b523e to your computer and use it in GitHub Desktop.
Save thiagomgo/46cefd4215cd4d827cedb0a74c1b523e to your computer and use it in GitHub Desktop.
Simple bash script to copy txt files to another directory.
#!/bin/bash
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
set -e
set -o pipefail
FROM="/tmp/FROM/"
TO="/tmp/TO/"
DATE=$(date '+%d-%m-%Y %H:%M:%S')
LOG_FILE=/scripts/rsync-txt-files.log
echo -e "Copying files txt from $FROM to $TO"
echo -e "=================================\n" >> $LOG_FILE
echo $DATE >> $LOG_FILE
rsync -avzh --out-format="%t %f %b" --include="*/" --include="*.txt" --exclude="*" "$FROM" "$TO" >> $LOG_FILE 2>&1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment