Created
December 4, 2019 17:11
-
-
Save terrymafura/53d14e2bc0b52743c3c800d438f3f889 to your computer and use it in GitHub Desktop.
Bash script that waits for a file in a directory and processes it then zips
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 characters
#!/bin/bash | |
TARGET=/<input_directory> | |
OUTPUT=/<output_directory>/ | |
inotifywait -m -e create -e moved_to --format "%f" $TARGET \ | |
| while read FILENAME | |
do | |
echo Detected $FILENAME, processing | |
# any instruction on the file here | |
mv "$TARGET/$FILENAME" "$PROCESSED/$FILENAME" | |
gzip "$OUTPUT/$FILENAME" | |
done | |
# Requires inotify-tools and gzip | |
# sudo apt install inotify-tools gzip |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment